Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

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

by tilly (Archbishop)
on Nov 10, 2005 at 15:36 UTC ( [id://507408]=note: print w/replies, xml ) Need Help??


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

Your first solution will misbehave if you run across a line like:
foo||bar
Your second solution can be shortened by 3 characters:
sub func { #23456789_123456789_123456789_12345678 chomp(@_=split'\|',pop);$p{+shift}=\@_ }
and one more if you're willing to replace chomp with chop.

Replies are listed 'Best First'.
Re^3: golf: shortest way to parse a pipe delimited file
by bageler (Hermit) on Nov 10, 2005 at 19:38 UTC
    this fails by giving an empty hash entry.
    $VAR1 = { '' => [], 'aaa' => [ 'bbb', 'ccc' ], 'foo' => [ 'bar', 'baz' ] };
      It doesn't fail for me with Perl 5.8.7.

      My best guess is that your input had a blank line in it at the start or the end. That blank line would (legitimately from the spec) result in the output that you saw.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-26 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found