my @file_list = `ls input_files`; # get the list of files from the input directory foreach (@file_list){ # loop through the files that are in the directory chomp; my $filename = 'input_files/'.$_; print "file name is : $filename\n"; open (my $fh, "< $filename" ) or die ("Can't open input file $!"); open (my $fh, "< $filename" ) or die ("Can't open input file $!"); while ( < $fh > ){ # look through the data in the file print; print "\n"; }