in reply to extract substring between token a and token b

This works... I'm not sure what the "%"s in your regex were for.
#!/usr/bin/perl $text = "<!--begin-->this is a line of text<!--end--><!--begin-->anoth +er one<!--end-->"; @lines = $text =~ /<\!--begin-->(.*?)<\!--end-->/g; foreach (@lines) { print $_ . "\n"; }

Peace!
LassiLantar