in reply to Grab "as many occurrences as there are" in a long string
Will output:use warnings; use strict; use Data::Dumper; my $string = "A dun dun B ignorable A something B\n"; my @contents = $string =~ /A (.*?) B/g; print Dumper \@contents;
With the key bits being the use of /g and assigning in list context.$VAR1 = [ 'dun dun', 'something' ];
If your strings can possibly overlap each other, then you've got more work to do, but it sounds like that is not the case here.
|
|---|