Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by bageler (Hermit)
on Nov 10, 2005 at 19:42 UTC ( [id://507514]=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

I see more than 41 characters because you say while (<SRC>) { } In my solution, the filehandle is part of the solution character count. If I put my solution in the context of yours it looks like this:
sub parse{ #12345678901234567890123456789012345678901234567890 %p=map{chomp;split/\|/;shift@_,[@_]}@_ } parse(<SRC>);
and is 37 characters.

Replies are listed 'Best First'.
Re^3: golf: shortest way to parse a pipe delimited file
by Roy Johnson (Monsignor) on Nov 10, 2005 at 20:06 UTC
    Save a couple of chars by taking advantage of the fact that shift defaults to @_ while in a sub.
    %p=map{chomp;split/\|/;shift,[@_]}@_
    Using chop instead of chomp would help, but might not be portable.

    Caution: Contents may have been coded under pressure.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2024-03-28 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found