in reply to Re^2: golf: shortest way to parse a pipe delimited file
in thread golf: shortest way to parse a pipe delimited file

Update: Oh crap!

In that case, gotcha by 1 :)

perl -F'\|' -lane'($k,@v)=@F;$f{$k}=\@v'

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: golf: shortest way to parse a pipe delimited file
by sauoq (Abbot) on Nov 12, 2005 at 23:58 UTC

    Not quite. That @v is global... you need [@v] because you won't be making a copy otherwise. Here's mine...

    356,0 sauoq@fozzie:~$ perl -MData::Dumper -F'\|' -lane'($k,@v)=@F;$f{$ +k}=[@v]}{print Dumper \%f' foo|bar|baz qux|zab|oof $VAR1 = { 'qux' => [ 'zab', 'oof' ], 'foo' => [ 'bar', 'baz' ] };
    And yours...
    357,0 sauoq@fozzie:~$ perl -MData::Dumper -F'\|' -lane'($k,@v)=@F;$f{$ +k}=\@v}{print Dumper \%f' foo|bar|baz qux|zab|oof $VAR1 = { 'qux' => [ 'zab', 'oof' ], 'foo' => $VAR1->{'qux'} };

    -sauoq
    "My two cents aren't worth a dime.";