Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: What is true and false in Perl?

by jdporter (Canon)
on Oct 17, 2012 at 19:43 UTC ( #999597=note: print w/replies, xml ) Need Help??


in reply to Re^2: What is true and false in Perl?
in thread What is true and false in Perl?

print "true" if "IS" eq "evaluates to in scalar context"; # doesn't pr +int.

Replies are listed 'Best First'.
Re^4: What is true and false in Perl?
by Anonymous Monk on Oct 17, 2012 at 23:40 UTC
    what are you trying to say?

      The same thing tobyink and tye said, though more obtusely and snarkily.

      Here's another example:

      tie my $var, 'Some::BlackBox::Module'; $var = "45"; if ( $var ) { print "var is true\n" } # doesn't print! WTF?

      The mere fact that an expression evaluates to a true value in scalar context doesn't mean it is true.

      tie and overload are among the user-accessible features which can muddy the true/false waters.

      An example like this should make the principle more obvious:

      my $obj = ObjectWithLotsOfOpaqueStructure::AndLotsOfHiddenState->new( -use_overloading => 1, ); if ( $obj ) { print "obj is 'true'.\n"; # What does this even mean? # Maybe obj is an iterator with another available item? }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999597]
help
Chatterbox?
[Corion]: ambrus: Details ;)
[ambrus]: Like <c>{ package AnyEvent::Impl:: Prima; use Prima; sub io{ my($s,%r)=@_; Prima::File->new( file=>$r{fh},mask =>("w"eq$r{poll}? fe::Write():fe:: Read())|fe:: Exception,onRead =>$r{cb},onWrite =>$r{cb}, onException=>$r{cb }) } sub timer { ... } push @AnyEvent::REGI
[ambrus]: argh, too long, let me try on scratchpad
[Corion]: . o O ( I seem to have improved my skills of getting other people to write code for me )
[ambrus]: ambrus's scratchpad

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2016-12-08 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (141 votes). Check out past polls.