
BillKSmith
Veteran
Jan 18, 2011, 9:10 PM
Post #2 of 3
(192 views)
|
|
Re: [oppilif] working with multiple input files
[In reply to]
|
Can't Post
|
|
I think you want to store each file in its own array, and then make an array of these arrays. Refer to perldoc perllol for details.
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @input_files = @ARGV; verify_usage(@input_files); my @content; foreach my $file_name (@input_files) { open my $FILE, '<', $file_name or die "Cannot open '$file_name' for input\n"; my @text = <$FILE>; push @content, [@text]; close $FILE; } print Dumper \@content; sub verify_usage { my @input_files = @_; my $number_of_files = @input_files; if ( ($number_of_files == 0) || ($number_of_files > 12) || grep {!/\.dat$/i} @input_files ) { die "\nUsage: timelapse.pl inputfile1.dat inputfile2.dat ... \n"; } } Good Luck, Bill
|