Beware of grep in scalar context. You need to use parentheses to create list context.
Nowadays, i.e. with Perl 5.10, you don't have to specify how to match in the grep. Using the ~~ operator you can let $SearchStr handle that.
my $SearchStr = 'foo.txt'; #my $SearchStr = qr/^foo_.*\.txt\z/i; #my $SearchStr = [ 'foo.txt', 'bar.txt' ]; my ($grepresult) = grep { $_->[0] ~~ $SearchStr } @cdata;
lodin
In reply to Re^2: find a string in an array of arrays
by lodin
in thread find a string in an array of arrays
by jgatrell42
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |