while() { chomp; print "Matches like: ($1)($2)($3)\n" if m/^([^ ]+)([a-z0-9]+)([^ ]+)$/ } __DATA__ >>>>this<<<< $$$$that$$$$