If you're going to use grep that way, you're doing unnecessary work. Either rewrite that grep as a for loop or use List::Util::first.
my $index; for ( 0 .. $#csvlist ) { if ( $csvlist[$_] =~ /$x/ ) { $index = $_; last; } } use List::Util 'first'; my $index = first { $csvlist[$_] =~ /$x/ } 0 .. $#csvlist
In reply to Re^2: Array searching, grep, first
by diotalevi
in thread Array searching, grep, first
by jimbus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |