Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Hash Printing reveals Hash Memory Location

by tobyink (Canon)
on Feb 03, 2012 at 07:51 UTC ( #951623=note: print w/replies, xml ) Need Help??


in reply to Re: Hash Printing reveals Hash Memory Location
in thread Hash Printing reveals Hash Memory Location

The expression $english && $foreign will evaluate to either true (1) or false ("") but will never be equal to '-1'.

Wrong. The "&&" operator doesn't return 1 or "". It returns the expression on the right side of "&&" if and only if both expressions are true.

use 5.010; my $english = 'foobar'; my $foreign = -1; say ($english && $foreign); # says "-1" say ($foreign && $english); # says "foobar"

Replies are listed 'Best First'.
Re^3: Hash Printing reveals Hash Memory Location
by lidden (Curate) on Feb 04, 2012 at 00:59 UTC
    It returns the expression on the right side of "&&" if and only if both expressions are true.
    It returns the expression on the right side if the expression on the left side is true.
    $ perl -E 'say "Yes" if "Foo" && 0 eq 0' # says "Yes" $ perl -E 'say "Yes" if "Foo" && "" eq ""' # says "Yes" $ perl -E 'say "Yes" if "Foo" && 0 eq ""' # Nothing

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://951623]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2023-11-29 18:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?