Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: golf anyone? (taking first field)

by Arien (Pilgrim)
on Jan 07, 2003 at 07:56 UTC ( [id://224903]=note: print w/replies, xml ) Need Help??


in reply to golf anyone? (taking first field)

For 26 strokes:

# 1 2 #2345678901234567890123456 map/(.+?)\s*(?>:|$)/,@list

Update: Also eliminating lines that contain just a colon and optional whitespace. 28 strokes:

# 1 2 #234567890123456789012345678 map/(.+?)\b\s*(?>:|$)/,@list

— Arien

Replies are listed 'Best First'.
Re: Re: golf anyone? (taking first field)
by John M. Dlugosz (Monsignor) on Jan 07, 2003 at 08:32 UTC
    Ah, so the \b makes the match fail, and thus nothing gets emitted to the result list in the map? Is that Kosher? That is, the pattern in list context returns all the captured things, but normally $1 etc. are improper to use after a match fails; they sometimes have garbage even. But using the result as list context doesn't have the same problem, because it "knows" it iterated zero times. Very interesting!

    This is why golf is so interesting. Many thanks for the masterful demonstration.

    —John

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (2)
As of 2025-01-14 05:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (38 votes). Check out past polls.