Mathew Snyder schreef: > Dr.Ruud: >> flotsan: >>> it is told the following two statements are >>> different: >>> >>> 1) if ($_ = <STDIN>) { print; } # suboptimal: doesn't test defined >>> 2) if (defined($_ = <STDIN>)) { print; } # best >>> >>> But as I see it, these two do the same thing >> >> perl -le ' >> print defined($_) ? "\"$_\"" : "<undefined>" >> , "\tis " >> , $_ ? "true" : "false" >> for undef, "", 0, "0", 0E0, "0E0", 0.0, "0.0", 1 >> ' > > That's over my head...
Just play with it then. This is equivalent: #!/usr/bin/perl use warnings ; use strict ; local $\ = "\n" ; my @test = (undef, '', 0, '0', 0E0, '0E0', 0.0, '0.0', (), \(), \undef, 1) ; for (@test) { print defined($_) ? "'$_'" : '<undefined>' , "\tis " , $_ ? 'true' : 'false' ; } -- Affijn, Ruud "Gewoon is een tijger." -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>