in reply to Changing array by changing $_?
As ikegami and wol hinted at, apply from List::MoreUtils is a good tool to use here.
use List::MoreUtils qw(apply ); my @bad_species = grep { !exists $refspecies{$_} # find undefined names } apply { s/^-//; # normalize species names } @species; if( @bad_species ) { my $bad = join ', ', @bad_species; die "These values are not in the species table: $bad\n"; }
List::MoreUtils has many simple little functions that can make your code much easier to read and maintain.
TGI says moo
|
|---|