I am having a problem reading input from a file into an array. My simple code is:
#***********************************************************
#!usr/bin/perl
open DATA, "<test.dat";
chomp(@strings = <DATA>); #read the lines, not the newlines
print "@strings";
close DATA;
#***********************************************************
where the datafile 'test.dat' contains something simple, something like:
a 5 4 3
b 4 5 8
d 1 4 2
c 0 0 8
All I want to do is read each line into an element of an array, @strings, without the newline characters. When I run the above code, however, it will only print out 'c 0 0 8'. How come it doesn't print out all of the elements? This works fine if the input comes from <STDIN>. What am I missing here?
Thanks