[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



    Christopher> Can someone tell me what is wrong with the following
    Christopher> code?  $self->{'CONNECTION'}->disconnect(); undef
    Christopher> $self->{'CONNECTION'}; print "connection is not
    Christopher> undef\n" unless $self->{'CONNECTION'};

    Christopher> It seems that The message it printed out.

As it should since you print if $self->{CONNECTION} is false ('unless
EXPR' is just syntactic sugar for 'if !(EXPR)').  The undef stores
undef in the hashref for that key (which is false in boolean context),
so you've basically got 'EXPR if !$self->{CONNECTION}' which will
always run since you've just set it to a false value.


Perhaps you mean:

print "connection is not undef\n" if defined $self->{CONNECTION};


-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org|  Vincent, you should cease askin'          \ o.O'
                      |  scary questions." -- Jules                =(___)=
                      |                                               U


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00136" href="msg00136.html">[ale] undef problem.</a></strong>
<ul><li><em>From:</em> cfowler at outpostsentinel.com (Christopher Fowler)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00137.html">[ale] Channel Bonding [was] Linux compatible ethernet quad card?</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00139.html">[ale] A casualty of POP moves</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00136.html">[ale] undef problem.</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00139.html">[ale] A casualty of POP moves</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00138"><strong>Date</strong></a></li>
<li><a href="threads.html#00138"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>