nagalenoj has asked for the wisdom of the Perl Monks concerning the following question:
I was using ! operator today, and I notice a case where I expected a different output.
When I do !0, it results 1. But, when I do !1, it is neither returning 0 nor undef.
use 5.10.0; use strict; use warnings; my $r = !1; if (defined $r) { say "Defined"; } else { say "Not defined"; }
I don't understand, why it works this way. Help me to know what's happening in perl when I do this operation.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: how ! operator works
by davido (Cardinal) on Feb 04, 2011 at 08:14 UTC | |
by moritz (Cardinal) on Feb 04, 2011 at 08:51 UTC | |
by arkturuz (Curate) on Feb 04, 2011 at 09:12 UTC | |
by bart (Canon) on Feb 04, 2011 at 14:20 UTC | |
by ikegami (Patriarch) on Feb 04, 2011 at 20:48 UTC | |
by arkturuz (Curate) on Feb 04, 2011 at 22:23 UTC | |
| |
by moritz (Cardinal) on Feb 04, 2011 at 09:44 UTC | |
by !1 (Hermit) on Feb 04, 2011 at 18:53 UTC | |
Re: how ! operator works
by ikegami (Patriarch) on Feb 04, 2011 at 08:44 UTC | |
Re: how ! operator works
by Fletch (Bishop) on Feb 04, 2011 at 15:39 UTC | |
Re: how ! operator works
by Deepthi (Initiate) on Feb 04, 2011 at 17:14 UTC |
Back to
Seekers of Perl Wisdom