On Sat, 21 Feb 2004 21:23:13 -0600 Perl Mail User <[EMAIL PROTECTED]> wrote:
> Hello All, > > I have a basic question, I am new to perl, and I would like to try > and get a basic question answered, if possible. I have a file with > about 63 lines in it, I am running it through a basic perl program > that reads every line and prints it to the screen. I am trying to > get the output of each line into an @array, but all I am getting is > the last line in the file. Any help would be great. > > Script .... Like I said it is basic. > > __begin__ > > #!/usr/bin/perl > > open(FILE, "file1.txt") || die "Can not open file. $! \n"; > while ($line = <FILE>) { > if ($line =~ /:58/) { > #print $line; ## For Debugging Only > foreach ($line) { > @lines = $line; > } > } > } > print "@lines"; > > __end__ I think you need to change > foreach ($line) { > @lines = $line; to push(@lines,$line); Your foreach loop is in the inner most loop, so your @lines is only going to be the last line, though the systax is improper. -- Owen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>