>>>>> "SHC" == Shawn H Corey <shawnhco...@gmail.com> writes:

  SHC> Dr.Ruud wrote:
  >> Jeff Peng wrote:
  >> 
  >>> so how about while (my $line = <FILE>) instead of using $_?
  >> 
  >> Evil! An empty line, or a line with only a "0" in it.
  >> 

  SHC> Not quite.  Lines are not completely empty.  A blank line would have
  SHC> "\n".  A line with just zero would have "0\n".  Only after a chomp would
  SHC> the test fail.

  SHC> WARNING:  Evil code, do not use:
  SHC>   while( chomp( my $line = <FILE> )){

that is even more evil as it checks the result of chomp which is the
character chomped. a partial line without a trailing $/ (typically
newline) will fail that test as nothing gets chomped.

uri

-- 
Uri Guttman  ------  u...@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to