Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Constant code

by toolic (Bishop)
on Jan 20, 2017 at 15:33 UTC ( [id://1180018]=note: print w/replies, xml ) Need Help??


in reply to Constant code

Tip #6 from the Basic debugging checklist: Check to see if your code is what you thought it was

perl -MO=Deparse -p code.pl sub aa { 2; } sub bb { 2; } LINE: while (defined($_ = <ARGV>)) { my($a, $b) = (aa(), bb()); my($s, $t) = (2 * aa(bb()), 2 * $a + $b); # <-------- bb is inpu +t to aa 'STDERR'->say("$a==", aa()); 'STDERR'->say("$b==", bb()); 'STDERR'->say("$s==$t"); } continue { die "-p destination: $!\n" unless print $_; }

One fix: add parens:

# v v my ($s, $t) = (((2*aa)+bb), (2*$a+$b));

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 05:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found