3 ms·
Thanks for your answer. I'm very aware how to search an array in Perl. I really concentrated to much on searching in my text, whereas the critic should have be
by buster 15y ago
Thanks for your answer.
I'm very aware how to search an array in Perl. I really concentrated to much on searching in my text, whereas the critic should have been for array handling in general which i find far more inferior to other languages. From my other comment:
Example: Looking for an element and deleting it? (Taken from perlmonks.org)
my @array = qw( your array here );
my $search_for = "here";
my( $index )= grep { $array[$_] eq $search_for } 0..$#array;
splice @array, $index, 1
I'm sorry, but this is hideous, really. Just to show you an example of what "modern" languages can do:
array = ["a", "b", "c", "d"]
search = "b"
array.remove(search)
print array
['a', 'c', 'd']
They may have nearly the same amount of loc but imo the second one is by far more readable and not as error prone to typos or simple bugs as the Perl one.
- Mithaldu 15y agoI guess i'll have to repost this here. :) The correct answer should've been: @list = grep { $_ ne 'dogfood' } @list;