in reply to Re^3: Splitting file into separate files based on record lengths and identifiers
in thread Splitting file into separate files based on record lengths and identifiers

As I mentioned in Re^3: Splitting file into separate files based on record lengths and identifiers, I suspect your issue is that you are not anchoring your regular expressions. What happens when you change lines like:

if( s{ (\d+) \% }{}msx ){

to

if( s{ ^ (\d+) \% }{}msx ){