foreach (@data) { my $match = $_ if /testdir/; }