Hello!

What's the best way to delete multiple indices from an array?

i'm doing:

---------------
my @array=qw/zero one two three four five six seven eight nine ten/;

my @indicesToDelete = (2,4,6,7);

my %hash;

@hash{(0..scalar(@array)-1)} = @array;

delete $hash{$_} for @indicesToDelete;

@array = values(%hash);

--------------

but this doesn't seem to me much efficient. Is there a better way to do
this?

Btw, for this case the order doesn't matter.

Thanks!

Best regards,
David Santiago

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to