Your indices are wrong. The expression 1..-2 returns an empty list. See Range Operators in perlop. This will work if you either use 2 positive (@line_array = @line_array[1 .. @line_array-2];) or 2 negative (@line_array = @line_array[1-@line_array .. -2];) limits on the range.