Just a FYI:
open my $in, ...
...is not backward compatible. It's a perl 5.6+ feature. Also you don't need to explicitly close the file handle using this method as it is done automatically.
Also as you don't need Begin/End you can change:
(Begin|End)
to:
(?:Begin|End)
open my $in, ...
...is not backward compatible. It's a perl 5.6+ feature. Also you don't need to explicitly close the file handle using this method as it is done automatically.
Also as you don't need Begin/End you can change:
(Begin|End)
to:
(?:Begin|End)