map{/([^:]*?)(\s*\n|\s*:)/&&$1}@list; # silly me ... distributive property! update: 34 chars: map{/([^:]*?)\s*(\n|:)/&&$1}@list; #### __DATA__ 123 : oain:b:okfbd 456 foo bar : df a dsaf asdf 111 : #### map{(split/\s*(:|\n|$)/)[0]}@list;