while ( my $blah = ) { if (my ($filename) = ($blah =~/(\w+\.pl)/i) ) { print "$filename was found.\n"; } else { print "no match.\n"; } }