I like graff's suggestion of using the s modifier in your regex if the file's slurped into $filedata. Given that, here's another solution to grabbing those two sections, and it then places them into an array of arrays @arrBlocks (where $arrBlocks[0] is an array of the first block's elements and $arrBlocks[1] is an array of the second block's elements):
for($filedata =~ /#begin\d*?\n(.*?)#end\d*?\n/gs) { push @arrBlocks, [split "\n"]; }
The regex matches your pattern and can be used for endless #begin/#end pairs that end with digits (e.g., #begin3/#end3, ...). If you started with #begin0/#end0, then $arrBlocks[0] would contain that block's elements.
Hope this helps!
In reply to Re: grab 2 blocks of texts from file
by Kenosis
in thread grab 2 blocks of texts from file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |