in reply to Split on new line

One issue can be resolved by adding use strict; use warnings; to your code. You will get messages to the effect that $file is not defined (amongst other things).

When you slurp all lines of your file into @file, each element of the array should contain one line ending in a newline character. You can prove this by printing the contents of the array as follows:

use Data::Dumper; print Dumper(\@file);

If you then want to remove the newline characters, use chomp:

chomp @file;