in reply to "last expression" quiz
I don't understand how can it be at the same time defined, == 0, and eq "".
This is easy. The return value is the empty string !1† as bart says.
$ perl -le 'print "yes" if defined ""' yes $ perl -le 'print "yes" if 0 == ""' yes $ perl -le 'print "yes" if "" eq ""' yes
The bigger question you are asking—basically, why the empty string is returned—doesn't seem to have such a clear answer. This has come up recently in the discussion that followed Re^4: Unhappy returns. You'll find a closer look at the more general issue including how other statements are handled there. FWIW, I think it should probably be considered a bug. I'm pretty sure it isn't documented.
Which is exactly the same as the empty string only, uh, different It doesn't cause warnings where an empty string would.
Edit: Corrected "empty string" to !1 per bart's response below and added footnote.
-sauoq "My two cents aren't worth a dime.";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: "last expression" quiz
by fxn (Sexton) on Oct 19, 2005 at 22:21 UTC | |
by bart (Canon) on Oct 19, 2005 at 22:27 UTC | |
by Aristotle (Chancellor) on Oct 19, 2005 at 22:32 UTC | |
by sauoq (Abbot) on Oct 19, 2005 at 22:36 UTC | |
by japhy (Canon) on Oct 19, 2005 at 23:12 UTC | |
by Aristotle (Chancellor) on Oct 19, 2005 at 22:42 UTC | |
| |
by Aristotle (Chancellor) on Oct 19, 2005 at 22:58 UTC | |
by sauoq (Abbot) on Oct 19, 2005 at 22:44 UTC | |
by bart (Canon) on Oct 19, 2005 at 22:48 UTC | |
|
Re^2: "last expression" quiz
by fxn (Sexton) on Oct 20, 2005 at 09:27 UTC | |
by sauoq (Abbot) on Oct 20, 2005 at 09:38 UTC | |
by halley (Prior) on Oct 20, 2005 at 14:08 UTC |