Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Can you explain the result?

by RMGir (Prior)
on Dec 06, 2011 at 13:20 UTC ( #942013=note: print w/replies, xml ) Need Help??


in reply to Can you explain the result?

Sure. The result of your function is the value 1, and that's what you're passing to Dumper...

Now, if you called

print Dumper(\&func);
on the function reference, you'd get a slightly more interesting result:
$VAR1 = sub { "DUMMY" };
I guess my version of Dumper isn't up to decompiling subs - I'm guessing that's expected.

Mike

Replies are listed 'Best First'.
Re^2: Can you explain the result?
by PerlOnTheWay (Scribe) on Dec 06, 2011 at 13:24 UTC
    shouldn't  1 and 0 be false/0?
      As choroba said, return 1&&0 is different from return 1 and 0.

      $ perl -MB::Deparse -e' sub f{return 1 and 0;}; sub g{return 1 && 0}; $deparse=B::Deparse->new(); print "f(): ",$deparse->coderef2text(\&f),"\n"; print "g(): ",$deparse->coderef2text(\&g),"\n";' f(): { 0 if return 1; } g(): { return 0; }

      Mike
        I think it's bad design

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://942013]
help
Chatterbox?
erix . o O( "what fools the french are, Jeeves" )
[choroba]: Also some Достое́вс кий
[Discipulus]: mmh windows understand something like: cd c:\\\\path\\\\to weird..

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (11)
As of 2017-05-24 08:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?