#!/usr/bin/perl @val = ( "aBaBaBBaa: aBaBaB: aBaBaB", " message-ad : ", "Message-Id blabla", " aaaa : aaaaa BBBB", " aaaa : aaa:aa BBBB", "", ); foreach $val (@val) { $val = $val; print "[$val]", "\n"; $val =~ s/^\s*(.+?):(.+)$/\U$1\E:$2/; print "[$val]", "\n\n"; }