my $one = qr{ one (? \d+ ) }xi; my $two = qr{ $one two (? \d+ ) }xi; "One9Two8Three7" =~ m{ $two three (? \d+ ) }xi; use Data::Dump; dd \%+; __END__ { # tied Tie::Hash::NamedCapture one => 9, three => 7, two => 8, }