use Regexp::NamedCaptures; $_ = "three - four - five"; /(\w+)\C{baz} - (\w+)\C{qux}/g; print "baz=$baz, qux=$qux\n";