#!/usr/bin/perl -- use strict; use warnings; use Data::Dump qw/ dd /; my $cool = qr/ (? \s* (?\w+) \s* (?\w+) \s* (?\d*) ) /x; my $beans = 'castor cocoa coffee pinto navy Mayocoba'; while( $beans =~ m{$cool}g ){ dd( \%+ ); } __END__ { # tied Tie::Hash::NamedCapture key => "castor cocoa ", key2 => "castor", keyQ => "cocoa", NEVER => "", } { # tied Tie::Hash::NamedCapture key => "coffee pinto ", key2 => "coffee", keyQ => "pinto", NEVER => "", } { # tied Tie::Hash::NamedCapture key => "navy Mayocoba", key2 => "navy", keyQ => "Mayocoba", NEVER => "", }