my @array = map { ["$_:", 1, 2, 3] } (0..3); foreach (@array) { print join (', ', @{$_}) . "\n"; }
HTH, David On Wed, 13 Oct 2004 14:44:06 +0100, Beckett Richard-qswi266 <[EMAIL PROTECTED]> wrote: > Guys, > This script: > > use strict; > use warnings; > my @array; > for (0..3) { > push @array, ["$_:", 1, 2, 3]; > } > for (0..$#array) { > my $row = $_; > for (0..3) { > my $col = $_; > print "$array[$row][$col], " unless ($col == 3); > print "$array[$row][$col]\n" if ($col == 3); > } > } > > Gives: > 0:, 1, 2, 3 > 1:, 1, 2, 3 > 2:, 1, 2, 3 > 3:, 1, 2, 3 > > Which is what I'd expect, and is designed to put the data into a csv file. > > First, is this the best way to do it, or is there a neater trick? > > Second, how would I print the results if I didn't know that each individual array > was 4 elements long (i.e. the sub arrays could be random lengths)? > > Thanks. > > R. > _______________________________________________ > Perl-Win32-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs