Here's my shot (
37 chars):
map{/([^:]*?)(\s*\n|\s*:)/&&$1}@list;
# silly me ... distributive property! update: 34 chars:
map{/([^:]*?)\s*(\n|:)/&&$1}@list;
I tested it with the following data and it seemed to work correctly:
__DATA__
123 : oain:b:okfbd
456
foo bar : df a dsaf asdf
111 :
It doesn't work when the input line contains only whitespace, but it does work for blank (other than the \n) lines. It returns empty string when the colon is the first non-whitespace. I don't know if this is correct behavior or not, though! This is my first golf attempt, so I may have missed some regex shortening tricks.
Update: Here's a slightly different approach that's the same 34 chars, although it behaves differently. This one does ignore lines of complete whitespace. It still gives empty string when a colon is the first non-whitespace in the line.
map{(split/\s*(:|\n|$)/)[0]}@list;
blokhead