cburns has asked for the wisdom of the Perl Monks concerning the following question:
here's the file:#!/usr/local/bin/perl # server.pl, my mini-server in perl open(FILE1, $ARGV[0]); while (<FILE1>) { @lines = $_; } print "lines[0] = $lines[0]\n"; print "lines[1] = $lines[1]\n"; print "lines[2] = $lines[2]\n";
and here's the output:> more test4a.txt POST /cgi-bin/myprog.cgi HTTP/1.0 UserAgent: MyBrowser Referer: http://www.rutgers.edu Content-type: application/x-www-form-urlencoded Content-length: 16
Do I need to have '\n' at the end of each line in the file, and then use split on the '\n' ? The program seems to be reading the entire file and placing the last line only into the array.> ./server.pl test4a.txt lines[0] = Content-length: 16 lines[1] = lines[2] =
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Parsing a file one line at a time
by ar0n (Priest) on Jul 23, 2000 at 00:34 UTC | |
|
RE: Parsing a file one line at a time
by autark (Friar) on Jul 23, 2000 at 00:38 UTC | |
by Anonymous Monk on Jul 23, 2000 at 21:08 UTC | |
by Ovid (Cardinal) on Jul 23, 2000 at 21:17 UTC | |
|
Re: Parsing a file one line at a time
by fundflow (Chaplain) on Jul 23, 2000 at 01:29 UTC | |
by chromatic (Archbishop) on Jul 23, 2000 at 08:34 UTC | |
|
Re: Parsing a file one line at a time
by cburns (Novice) on Jul 23, 2000 at 03:04 UTC |