in reply to Passing user input to a shell command

In addition to comments made by the other monks, I'd also suggest you move to the three argument open and lexical filehandles.

So, instead of

open(IN, $file) or die "The file $file". "is not present.\n";

use

open my $IN, "<", $file or die "can't open $file: $!";