I am trying to grab free tags from comments in a program using Perl and the Regexp::Grammars CPAN module.
use strict; use v5.10; use YAML; my $s = q{ junk code; // here be tags #:tag1: junk code 2; // another one #:tag2: junk ...; }; my $rg = do { use Regexp::Grammars; qr{ <nocontext: > ^ .* <Tagger> .* $ <rule: Tagger> <[MATCH=single_tag]> + <token: single_tag> \#\:<tag>\: <token: tag> <matchline> \w+ }xms; }; if( $s =~ $rg ) { say Dump( \%/ ); } else { say 'no match'; }
But the output of YAML shows that I only commit the last tag:
How can I match all tags from input?
And ... how can I get the correspondence of a tag line without including noisy context lines (removing the nocontext: directive), so that the final result is somewhat readable, i.e.
source share