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.


One way ...

perl -e
'@array1=(1..5);@array2=(A..K);@array3=(100..110);@ref=([EMAIL PROTECTED],[EMAIL 
PROTECTED]
2,[EMAIL PROTECTED]); foreach (@ref){print ++$i,":", join(",",@{$_}), "\n";}'
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to