Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

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

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

very nice, but unfortunately my command line doesn't like it at all:
Bareword found where operator expected at -e line 1, near "0F" (Missing operator before F?) syntax error at -e line 1, near "}=" Execution of -e aborted due to compilation errors.
This is how you'd score it:
#1234567890123456789012345678901234567890123456789012345 perl -anF"\|" -le"$f{shift@F}=[@F[1..$#F]]" pipe.txt
42.

Replies are listed 'Best First'.
Re^3: golf: shortest way to parse a pipe delimited file
by BrowserUk (Patriarch) on Nov 10, 2005 at 20:16 UTC
    my command line doesn't like it at all

    Then adapt it to your shell. Something like this might work,

    perl -anF'|' -le'$f{shift@F}=[@F[1..$#F]]' pipe.txt

    but I don't use your shell so that is a guess, and I cannot test it as it wouldn't work on my shell.

    This is how you'd score it:

    That doesn't seem quite fair, as to use your example, you would need at least this to make it work:

    #!/usr/bin/perl #12345678901234567890123456789012345678901234567890123456789012345 open SRC, '<pipe.txt';%prod=map{chomp;split/\|/;shift@_,[@_]}<SRC>

    Which I get to be a total of 89 and that's without the command line to run it!


    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.
      the context is that of a subroutine though. You go out of context and the rules change ;)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 22:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found