#!/usr/bin/perl -w use strict; use File::Find; my($find, @directories) = (@ARGV); unless (scalar @directories) { print "Usage: find.pl FINDSTRING DIR1...\n"; exit; } find(\&do_this, @directories); exit; sub do_this { if(! -f $_) { # if it's not a regular file skip it return; } if(open(F, $_)) { undef $/; my $file = ; if((defined $file) && ($file ne '') && ($file =~ /\Q$find\E/giso)) { # the if defined was added # later after I realized that an # empty file would leave $file undef! print "$File::Find::name\n"; } close(F); } else { warn "Unable to open '$_': $!"; } }