open(INP, "<$file_list") or die("Error reading file"); while () { my $data_file = m/(\w+)/; # I then call a subroutine which opens the $data_file # and performs some analysis on it } #### open(INP, "<$file_list") or die("Error reading file"); @lines = ; while (@lines) { my $data_file = m/(\w+)/; # I then call a subroutine which opens the $data_file # and performs some analysis on it }