Thanks for the idea, but I don't quite understand what
<code>
$"="\n";
<code>
is from. I haven't see it in Learning Perl and I'll have to read how it works with the string. It is a nice trick, it seems like a shortcut to concatenate a common command to every string in the array.
$" is the list separator, see perldoc perlvar:
its value is placed between list/array/slice values when the list is interpolated into a doublequoted string.