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

This will do it, but I don't know how you would score it for comparison.

Well, no matter how you score it, I gotcha by two. :-)

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

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

Replies are listed 'Best First'.
Re^3: golf: shortest way to parse a pipe delimited file
by BrowserUk (Patriarch) on Nov 12, 2005 at 23:40 UTC

    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.

      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.";