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
In reply to Re: Changing array by changing $_?
by TGI
in thread Changing array by changing $_?
by johnvandam
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |