Rather than a global match you could use a while statement modifier.
knoppix@Microknoppix:~$ perl -E ' > $file = <<EOD; > some data; comment 1 > more data; comment 2 > even more data; comment 3 > EOD > push @comments, $1 while $file =~ s{(;[^\n]*)}{*MARKER*}; > say $file; > say for @comments;' some data*MARKER* more data*MARKER* even more data*MARKER* ; comment 1 ; comment 2 ; comment 3 knoppix@Microknoppix:~$
I hope this is of interest.
Cheers,
JohnGG
In reply to Re: s///g and capturing all matches
by johngg
in thread s///g and capturing all matches
by Random_Walk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |