Heh! I recognise some of that code :) _And_ you're planning to use one of my modules to do the array comparison.
In general, if you have a list of filenames and want to get a list of file contents then you'd better be sure that the files are small or you've got a lot of memory! That being said, you can do it like this:
my @files = qw(file1 file2 file3); my @contents; foreach (@files} { open FILE, $_ or do { warn "Can't open $_: $!\n"; next } local $/; push @contents, <FILE>; }
This gives you each file's contents in a scalar. To get an array of each file's contents you'd do this:
--my @files = qw(file1 file2 file3); my @contents; foreach (@files} { open FILE, $_ or do { warn "Can't open $_: $!\n"; next } push @contents, [<FILE>]; }
"Perl makes the fun jobs fun
and the boring jobs bearable" - me
In reply to Re: Arrays of files from an array of file names
by davorg
in thread Arrays of files from an array of file names
by Tuna
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |