Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^4: What is true and false in Perl? (undef,undef)

by amartyaj (Initiate)
on Nov 22, 2013 at 18:00 UTC ( #1063972=note: print w/ replies, xml ) Need Help??


in reply to Re^3: What is true and false in Perl? (undef,undef)
in thread What is true and false in Perl?

Hi can somebody explain to me the reason behind the following: test.pl: #!/usr/bin/perl my $a = (1==0); print "__".ref($a)."__\n"; Output: ____


Comment on Re^4: What is true and false in Perl? (undef,undef)
Replies are listed 'Best First'.
Re^5: What is true and false in Perl? (undef,undef)
by davido (Archbishop) on Nov 22, 2013 at 18:11 UTC

    What do you think ref does?

    In your example code, $a doesn't contain a reference. It contains a false value. ref does exactly this: "Returns a non-empty string if EXPR is a reference, the empty string otherwise."


    Dave

      Got it. Thanks a lot Dave.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2015-07-08 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (96 votes), past polls