On 04/12/2017 04:01 PM, David Emanuel da Costa Santiago wrote:
Thanks for your reply. I didn't think about that! :-)
While i was reading your email, i remembered about splice, so i guess
i'm going to end up with:
----------
my @array=qw/zero one two three four five six seven eight nine ten/;
my @indicesToDelete = (2,4,6,7);
my $deviation = 0;
splice(@array, $_-$deviation++,1) for(@indicesToDelete);
splice isn't efficient there as it has to shift down the rest of the
array after the excised element. and you are calling it in a loop which
makes it worse. try benchmarking my example vs your splice code. it is a
good exercise for you too! use Benchmark.pl which makes it easy and post
your code here so we can verify you are doing it correctly. benchmarking
the right way is an art unto itself.
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/