Hi, I'm trying to write a script that parses a file, which itself contains file names. I want to open each one of these files listed and perform some data analysis. However, I'm getting an error any way I try to do it.
Here is my original code (adapted)
open(INP, "<$file_list") or die("Error reading file"); while (<INP>) { my $data_file = m/(\w+)/; # I then call a subroutine which opens the $data_file # and performs some analysis on it }
I wasn't surprised the above didn't work, since INP would have to be closed for the other file to be read in the subroutine I called. However, the following did not work also:
open(INP, "<$file_list") or die("Error reading file"); @lines = <INP>; while (@lines) { my $data_file = m/(\w+)/; # I then call a subroutine which opens the $data_file # and performs some analysis on it }
I then get an error on uninitialized values. I could slurp the entire file into a string, and then use split to get the lines, but that seems like it would be costly. Any ideas?
In reply to Multiple files opened by kokakola613
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |