roho has asked for the wisdom of the Perl Monks concerning the following question:

I just finished tracking down a very elusive bug in my code. The bug was caused by two defined's side by side (a copy/paste error). Perl doesn't object at either compile time or at run time, but two defined's reverses the logic of the expression. In the sample code below the first "if" statement is False (as expected), but the second "if" statement is True because of the two defined's.

I suppose there may be a use case somewhere where the result of one "defined" is fed into another, but my first reaction was that this is a bug. What do other monks think about this? Is this a bug in Perl or a "feature"?

#!/usr/bin/perl use strict; use warnings; my $x; if (defined $x) { print "True\n"; } else { print "False\n"; } if (defined defined $x) { print "True\n"; } else { print "False\n"; }

"Its not how hard you work, its how much you get done."