in reply to file not being split at new lines

My guess is that your Javascript file does not have the line endings that Perl thinks are normal for your system. What is the value of $\ (output it as hex using unpack 'H*', $\)?

Caution: Contents may have been coded under pressure.