Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!rpi!bu.edu!nntp-read!composer From: composer@chem.bu.edu (Jeff Kellem) Newsgroups: comp.lang.perl Subject: Re: print ; Message-ID: Date: 7 Apr 91 20:26:04 GMT References: <1268@sicsun.epfl.ch> Sender: news@bu.edu.bu.edu Reply-To: composer@chem.bu.edu Organization: Boston University Chemistry Department Lines: 48 In-reply-to: brossard@sic.epfl.ch's message of 7 Apr 91 10:14:19 GMT In article <1268@sicsun.epfl.ch> brossard@sic.epfl.ch (Alain Brossard EPFL-SIC/SII) writes: > There is a feature which has just bitten me and made me > lose a lot of hours and I think the man page should reflect > this. When doing: > > print NEW ; > > It not only prints the next line of FILE as > I wanted but prints all the rest of FILE. There is a paragraph in > the 4.000 man page which relates to this (I think): > > If a is used in a context that is looking for > an array, an array consisting of all the input lines is > returned, one line per array element. It's easy to make a > LARGE data space this way, so use with care. > > At least that is what I think it says, this is what I would > call a feature in the bad sense of the word! Isn't Perl > cryptic enough? 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 ; > > 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 don't have to do the assignment. You just need to put the filehandle into a scalar context. You can do so using scalar(). So, to do what you wanted, try: print $_, scalar(), scalar(); That should do what you expected. Enjoy... -jeff Jeff Kellem Internet: composer@chem.bu.edu