in reply to Grab "as many occurrences as there are" in a long string

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;
Will output:
$VAR1 = [ 'dun dun', 'something' ];
With the key bits being the use of /g and assigning in list context.

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.