perl -e 'print ">",shift =~ /(\w(?{print ":$1"})){3}/' abc ::a:b>c