http://www.perlmonks.org?node_id=597304


in reply to search for a pattern in file without opening the file

Let perl do the dirty work and use the implicit loop options -n ( see perlrun ).

Check out Tim Mahers Minimal Perl if you are a unixy person and want perl scripts to work similar to unix tools.

/usr/bin/perl -n BEGIN{ @ARGV=qw(the files you want to process); } push @files, $ARGV and close ARGV if /^pattern/; END{ print "matching files @files\n" }