I was trying to think of how/why this would come about and ended up
thinking "hmm, maybe a dir full of data files, w/ each line of data being
delimited somehow, so:
use warnings;
use strict;
my @GAR;
my $file_count = 0;
my @current_array;
while (<>) {
chomp;
my @current_data = split(/\,/);
push(@current_array, [ @current_data] );
if ( eof ) {
$GAR[$file_count] = [ @current_array ];
@current_array = ();
$file_count++;
}
} # while <>
# a little much but to display in required format:
foreach my $arr ( @GAR ) {
print "[";
my $comma = "";
foreach my $data ( @{ $arr } ) {
print "${comma}\[", join(",", @{ $data }) , "]";
$comma = ",";
}
print "]\n";
}
using /tmp/arr1.txt (/tmp/arr2.txt etc) as:
1,2,3
5,6,7,8
9,10,11,12,13
gets
perl /tmp/arr.pl /tmp/arr*.txt
[[1,2,3],[5,6,7,8],[9,10,11,12,13]]
[[1,2,3],[5,6,7,8],[9,10,11,12,13]]
I believe the hash/ref confusions in the comment imply that there's other
things going on here and that this could be handled in a much better way,
if we had more info but ...
a
Andy Bach, Sys. Mangler
Internet: [EMAIL PROTECTED]
VOICE: (608) 261-5738 FAX 264-5932
Nationalism is an infantile sickness. It is the measles oft he human race.
Albert Einstein (Happy 126th)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs