Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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

by bageler (Hermit)
on Nov 10, 2005 at 19:42 UTC ( #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? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (1)
As of 2022-10-02 06:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (7 votes). Check out past polls.

    Notices?