use strict; use warnings; use diagnostics; use File::Slurp; #use Cwd; my @files; get_args(); sub get_args { print "enter path: "; chomp( my $dir = ); print "enter match string: "; chomp( my $string = ); @files = read_dir($dir); print "\n", $_ for @files, "\n" ; traverse( $dir, $string ); } sub traverse { my ( $dir, $string ) = @_; for my $element (@files) { open (my $file, '<', "$dir/$element") || next; while (<$file>) { if ( $_ =~ m/$string/i ) { print "found $string in $element\n"; } } close $file; } print "\n"; get_args(); }