in reply to golf anyone? (taking first field)
36 chars and handles blank lines, empty lines and lines starting with a colon:
Chokes if the values in front of the colon is '0'.@list = ( "123 : oain:b:okfbd", "", "456", "foo bar : df a dsaf asdf", "111 :", ": adf", " " ); $, = "\n"; print map{/(.*?)(\s*:|\s*$)/;$1||()}@list;
Update: 33 chars (destructive):
Update: 32 chars (destructive):map{s/\s*:.*|\s*$//;$_||()}@list;
map{s/\s*(:.*|$)//;$_||()}@list;
In Section
Seekers of Perl Wisdom