sub fgrep_dash_l{ my $pattern = shift; my @searchfiles = @_; my @found; foreach my $file (@searchfiles){ my $FH; open FH, $file or warn "error opening file $file" and next; while(){ push @found,$file and last if m/$pattern/; } } return @found; }