Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!mcnc!uvaarpa!mmdf From: worley@compass.com (Dale Worley) Newsgroups: comp.lang.perl Subject: print ; Message-ID: <1991Apr8.161504.2872@uvaarpa.Virginia.EDU> Date: 8 Apr 91 16:15:04 GMT Sender: mmdf@uvaarpa.Virginia.EDU (Uvaarpa Mail System) Reply-To: worley@compass.com Organization: The Internet Lines: 45 From: brossard@sic.epfl.ch (Alain Brossard EPFL-SIC/SII) print NEW ; It not only prints the next line of FILE as I wanted but prints all the rest of FILE. You've gotten bitten by the one truly non-obvious feature of Perl: You must always be aware of array vs. scalar context. 'print' provides an array context for its arguments. For better or worse, not knowing the contexts provided by all the operators one uses is as dangerous as not knowing the difference between $foo, $foo(1), and $foo{1}. Anyway I suggest adding: print ; in the paragraph that says that all the following are equivalent: while ($_ = ) { print; } while () { print; } for (;;) { print; } print while $_ = ; print while ; Well, that paragraph is discussing flow-of-control constructions, not array handling. I wanted to do print $_, , ; and I had to do: print $_ = ; print $_ = ; The fact that I need to do an assignment seems counter intuitive! You can do print scalar(); to execute in a scalar context, i.e., reading one line. Dale Dale Worley Compass, Inc. worley@compass.com -- I am successful because I am the only person in my city who is not heavily addicted to powerful narcotics.