... use Cwd qw(abs_path); ## module to get absolute pathname ... foreach my $my_file(@lines){ $my_file = abs_path($my_file); # get the absolute pathname of each file open my $fh2,'<',$my_file or die "can't open file: $!"; while(<$fh2>){ ... } } ...