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

Re: golf anyone? (taking first field)

by busunsl (Vicar)
on Jan 07, 2003 at 07:33 UTC ( #224893=note: print w/replies, xml ) Need Help??


in reply to golf anyone? (taking first field)

36 chars and handles blank lines, empty lines and lines starting with a colon:
@list = ( "123 : oain:b:okfbd", "", "456", "foo bar : df a dsaf asdf", "111 :", ": adf", " " ); $, = "\n"; print map{/(.*?)(\s*:|\s*$)/;$1||()}@list;
Chokes if the values in front of the colon is '0'.

Update: 33 chars (destructive):

map{s/\s*:.*|\s*$//;$_||()}@list;
Update: 32 chars (destructive):
map{s/\s*(:.*|$)//;$_||()}@list;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://224893]
help
Chatterbox?
[Your Mother]: My cat used to climb into the freezer when I opened it. Once I closed it and left him for 5 minutes hoping to disuade the habit. When I opened it expecting a cat eager to never return he just stared at me. Had to pull him out.
[Your Mother]: oiskuu, I think we should just be friends.
[marto]: the 'cool' place to hang out
[Your Mother]: ♫ Caffeine, caffeine, caffeine, caffeine. There will be answer, caffeine. ♫ ♬
[oiskuu]: Ahh, old cats with rheuma. I think (s)he was saying, "dude, NOT cold enough."

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (11)
As of 2017-12-18 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (489 votes). Check out past polls.

    Notices?