print "Enter a file to look up for: "; my $file = ; chomp $file; # Get rid of newline character exit 0 if ($file eq ""); # If empty string, exit. use File::Find; my $dir = # whatever you want the starting directory to be find(\&do_something_with_file, $dir); sub do_something_with_file { #.....count number of lines of the file and simply concatenate the lines. #.....$numlines[$i++] . each line etc. etc. }