1: foreach (<FILE>) {
   2: 	print;
   3: }
   4: 
   5: # or
   6: 
   7: while (<FILE>) {
   8: 	print;
   9: }

Replies are listed 'Best First'.
Re: Default Line in Loops
by I0 (Priest) on Dec 23, 2000 at 06:56 UTC
    The latter would use less memory, and start printing the first line sooner.
RE: Default Line in Loops
by BBQ (Curate) on Dec 27, 1999 at 19:01 UTC
    # but have you tried this? foreach (sort <FILE>) { print; } while (sort <FILE>) { print; }
      Personally, I'd do:
      print while <FH>;
      or even: print do { local($/), <FH> }; But think, for a moment, about:
      while (sort <FH>) { print; }
      You're now calling sort() in scalar context. It returns false, so that while() loop doesn't do jack. And I HIGHLY recommend against
      for (<FH>) { print; }
      Since that builds up a list of all the records in FH. -- japhy on EFnet, japh on DALnet, Jeff on Earth