Erasmo Perez wrote:
I would like to know how could I transform the following CSV file:

1,2,3,4,5,6
2,3,4,6,7,8,9
3,876,986,876,765
...
987,983,654,990,654
989,876,234,56,67

into the following CSV file:

1,2
1,3
1,4
1,5
1,6
2,3
2,4
2,6
2,7
2,8
2,9
3,876
3,986
3,876
3,765
...
987,983
987,654
987,990
987,654
989,876
989,234
989,56
989,67

    while (<>) {
        chomp;
        my ($first, @rest) = split /,/;
        print "$first,$rest[$_]\n" for 0..$#rest;
    }

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to