Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: golf: shortest way to parse a pipe delimited file

by BrowserUk (Patriarch)
on Nov 12, 2005 at 23:40 UTC ( [id://508045]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://508045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found