in reply to Stack table columns with hash of arrays

$ echo "foo1 1 4 7 foo2 2 5 8 foo3 3 6 9" | perl -e' my @data; while ( <> ) { push @data, [ split ] } while ( @{ $data[ 0 ] } > 1 ) { print map "$_->[0]\t@{[ splice( @$_, 1, 1 ) ]}\n", @data } ' foo1 1 foo2 2 foo3 3 foo1 4 foo2 5 foo3 6 foo1 7 foo2 8 foo3 9

Replies are listed 'Best First'.
Re^2: Stack table columns with hash of arrays
by robertkraus (Novice) on May 31, 2011 at 09:27 UTC
    Wow! This works pretty neatly, too! No need for a hash, and actually cool because this means there is no issue with sorting. It comes out as it goes in. Cool stuff!