What did you expect it to return?
Consider this
my $bar = 'asdf asdf asdf-rdf';
my $mor = () = $bar =~ /asdf(?:-rdf)?/;
my $gor = () = $bar =~ /asdf(?:-rdf)?/g;
my @gor = $bar =~ /asdf(?:-rdf)?/g;
warn scalar @gor;
die "$mor and $gor = @gor";
__END__
3 at - line 6.
1 and 3 = asdf asdf asdf-rdf at - line 7.
update:
It returns the number of times the entire pattern matched ( aka the number of total matches).
.
My apologies.
What's returned are the values of the capture buffers (parens create a capture buffer).
my $mor = () = $bar =~ /asdf(?:-rdf)?/;
could be rewritten as
my $gor = my @gor = $bar =~ /asdf(?:-rdf)?/g;
| MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!" |
| I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README). |
| ** The third rule of perl club is a statement of fact: pod is sexy. |