use strict; use warnings; use File::Find; use Getopt::Long; use Pod::Usage; use Carp; # Parse command line arguments and assign corresponding variables GetOptions ( 'r|rootdir=s' => \( my $rootdir = "./" ), 'p|pattern=s' => \( my $pattern = undef ), 'i' => \( my $case_sensitive = 0 ), 'v|verbose' => \( my $verbose = 0 ), ); unless ( defined $pattern ) { print < \&filefilter }, $rootdir); sub filefilter { return if /^\.+$/; open FILE, "<$File::Find::name" or carp "could not open file: $File::Find::name"; my $file = do { local $/; }; close FILE; print ">> ", $File::Find::name, "\n" if $file =~ /$pattern/; }