M
Matija Papec
Here is the problem which IMHO isn't trivialy(in one line) solvable in
perl5; I have two arrays of same length and want to remove elements from
them depending on %h(all values are just for illustration, there is no
relation between them),
my @arr1 = 30..60;
my @arr2 = 10..40;
my %h = (
33 => 'value',
43 => 'value',
45 => 'value',
51 => 'value',
53 => 'value',
);
Now, simple grep does a right thing,
@arr1 = grep exists $h{$_}, @arr1;
but it leaves me with @arr2 where corresponding elements to @arr1 should
also be removed(when removing n-th from @arr1, remove n-th from @arr2 too).
I ended up with simultaneous array rotation and I'm curios now if there is a
better way?
perl5; I have two arrays of same length and want to remove elements from
them depending on %h(all values are just for illustration, there is no
relation between them),
my @arr1 = 30..60;
my @arr2 = 10..40;
my %h = (
33 => 'value',
43 => 'value',
45 => 'value',
51 => 'value',
53 => 'value',
);
Now, simple grep does a right thing,
@arr1 = grep exists $h{$_}, @arr1;
but it leaves me with @arr2 where corresponding elements to @arr1 should
also be removed(when removing n-th from @arr1, remove n-th from @arr2 too).
I ended up with simultaneous array rotation and I'm curios now if there is a
better way?