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.
- Exception flow control - Exception objects
The former is in fact implemented in Perl core via eval { literal code block }. In earlier versions of Perl there were issues where DESTROY blocks, called on object destruction, were able to clobber $@, i.e. the error message. Thus Try::Tiny has become the preferred method of doing exception flow control:
Mind, that issue has been fixed in 5.14 ( http://perldoc.perl.org/perl5140delta.html#Exception-Handlin... ), so if you're above that, you can safely use eval for your exception flow control. Yes, evals can be nested. If it does it via local it won't even concern you. If it does it plainly you're in a bit of a bind, but in practice this kind of thing happens exceedingly rarely on CPAN outside of self-contained applications or testing/installing code. You die with an array reference containing the interesting exceptions. If you know what kind of exception you expect, you write code that interrogates the scalar for that. For example, if you're expecting an object of a certain type:handle_exception( $_ ) if blessed( $_ ) and $_->isa('Exception::Parse');
Because we're collectively still trying to decide how to best handle exceptions. In other languages you get a solution plopped in front of you and have to accept it because you cannot even implement your own exception handling. If they got it right, great. If they didn't ... welp.Anyhow, that was only the first part. The second part is Exception Objects, which is where a lot of the various CPAN modules come in. Since Perl does not provide a native exception object, you can return literally anything you wish and many people experimented to see which kind of exception object they wanted. The concensus for this has landed on Exception::Class.
Those recommendations are bullshit and that's where you're right. However the fact that you think Perl does not have tools to search through arrays shows a glaring gap in your knowledge. As i mentioned in another comment, Perl has excellent facilities for searching through arrays: