Can you please let me know how to make use of %+ so to match in a loop even if the submatch in a pattern string fails?
um, \d always fails :)
#!/usr/bin/perl --
use strict;
use warnings;
use Data::Dump qw/ dd /;
my $cool = qr/
(?<key>
\s*
(?<key2>\w+)
\s*
(?<keyQ>\w+)
\s*
(?<NEVER>\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 => "",
}
|