So line 36 seems to be
print MYFILE wrap("", "", <<"");
which means perl will wrap the following text until there is terminator "" (I never use confusing item like this, I always use END or UNTIL_END for simplicity.)
That terminator is then found on line 45 (the empty line), meaning next thing it processes is line 46:
else {
which doesn't make sense, since the previous if hasn't closed yet (the line 44 which has } is before the terminator "" so its treated as text for wrapping. Perl notices this and kindly suggest you this might be the culprit:
(Might be a runaway multi-line << string starting on line 36)
You need to swap lines 44 and 45 to first have terminator "" (empty line), then close the if with }. The second wrap in your example does this correctly.