my @arr = grep {/\[tab\]/ and s/^

//} split /<\/p>/, $contents; #### my @arr = grep /\[tab\]/, split /(?<=<\/p>)/, $contents; #### { local $/ = '

'; open (STR, '<', \$contents) or die "Opening string: $!\n"; @arr = grep /^

/ && /\[tab\]/, ; print "read $_\n" for @arr; }