[ create a new paste ] login | about

Link: http://codepad.org/KEvNAyzh    [ raw code | output | fork ]

chas.owens@gmail.com - Perl, pasted on Apr 4:
#!/usr/bin/perl

use strict;
use warnings;
use Data::Dumper;

my $pos = tell DATA;

my @tmp;
my @AoA;
while (<DATA>) {
    @tmp = split;
    push @AoA, \@tmp;
}

print "wrong:\n", Dumper \@AoA;

seek DATA, $pos, 0; 
@AoA = ();

while (<DATA>) {
    @tmp = split;
    push @AoA, [@tmp];
}

print "right:\n", Dumper \@AoA;
__DATA__
1 2 3
4 5 6
7 8 9


Output:
wrong:
$VAR1 = [
          [
            '7',
            '8',
            '9'
          ],
          $VAR1->[0],
          $VAR1->[0]
        ];
right:
$VAR1 = [
          [
            '1',
            '2',
            '3'
          ],
          [
            '4',
            '5',
            '6'
          ],
          [
            '7',
            '8',
            '9'
          ]
        ];


Create a new paste based on this one


Comments: