in reply to Alternative to using system grep

Just to throw in my implementation, if I were to write this I wouldn't just give it a directory name, I'd give it an array of files, assuming I could always just use glob("*") as one of its parameters. It'd end up like this:

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(<FH>){ push @found,$file and last if m/$pattern/; } } return @found; }