in reply to Uploading and reading file

Start with use strict;, use warnings;, and possibly use diagnostics;. You may have just been too aggressive in your trimming code, but I don't see where you declare $file before using it.

See also the section on Embedded newlines -- your line processing is fragile.

It is useful when you ask for help to make it easy for us to replicate your issue. Please include sample input, expected output, actual output, and code that compiles cleanly and illustrates your issue.

--MidLifeXis