And i need the list:$string = "bla bla bla [[en:English]][[de:German]][[ga:Irish]] bla bla + bla";
I can do this:qw(en de ga);
And then i get qw(en de ga) in @matches, but that's because i have only one pair of capturing brackets, which is a limitation. If i do, for example:@matches = ( $string = m/\[\[(en|de|ga):.+?]\]/g );
Then i'll get qw(en English de German ga Irish). Is there a clever way to get a list of all the results from one pair of capturing brackets? I tried using Perl 5.10's named captures and %-. Either it can't be done this way or i am doing incorrectly. I tried this:@matches = ( $string = m/\[\[(en|de|ga):(.+?)]\]/g );
i get this output:my $string = 'bla bla [[en:English]][[de:German]][[ga:Irish]] bla bla' +; if (my @matches = ($string =~ m/\[\[(?<lang>en|de|ga):(.+?)\]\]/g)) { say 'matches'; say 'matches: ', Dumper(\@matches); say 'minus : ', Dumper(\%-); say 'plus : ', Dumper(\%+); }
You see - only ('ga'), but is there some way to get:matches matches: $VAR1 = [ 'en', 'English', 'de', 'German', 'ga', 'Irish' ]; minus : $VAR1 = { 'lang' => [ 'ga' ] }; plus : $VAR1 = { 'lang' => 'ga' };
Thanks in advance for any help.$VAR1 = { 'lang' => [ 'en', 'de', 'ga' ] };
In reply to Getting a list of captures in Perl 5.10 by amir_e_a
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |