From: "Rob Dixon" <[EMAIL PROTECTED]> > "Jenda Krynicky" <[EMAIL PROTECTED]> wrote in message > 3E01E02F.17624.1ED52A1C@localhost">news:3E01E02F.17624.1ED52A1C@localhost... > > From: "Perl" <[EMAIL PROTECTED]> > > > This should work (but beware - it is untested :) > > > > > > Rob > > > > > > my @required = qw(head1 head6 head8); > > > my $line; > > > > > > for (<DATA>) > > > > It's much better to use > > while (<DATA>) > > > > This "for (<DATA>)" forces Perl to read the whole file into an array > > in memory. (Well ... unless the optimizer is bright enough to change > > the command to "while (<DATA>)". Not sure it is. You should not > > depend on the optimizer.) > > I agree completely. Also the optimiser shouldn't translate this to a > while() as optimisers aren't supposed to change code semantics at all.
I wonder what is the difference between a for (<DATA>) { ... } and while (<DATA>) { ... } from the code-inside-the-loop's point of view. The only thing that comes to mind is the $. variable (current line number in the file being read). > > P.S.: Rob, could you change the comment part of your mail address? > > It's kinda strange to see a post comming from "Perl". :-) > > Yes, my apologies for this. I used to receive and send the newsgroup > posts as emails and just today set up the perl.org NNTP server - > wrongly! Things should be correct now. Yep, thanks :-) Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]