sub fgrep_dash_l { my $search = shift; local $/ = $search; my @files; while (my $file = glob("*")) { open my $fh, "<", $file or warn "error opening $file: $!" and next; defined(my $buffer = <$fh>) or next; push @files, $file if substr($buffer, -length($search)) eq $search; } return @files; } @arr = fgrep_dash_l("IsFrequentlyUsed");