Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Constant code

by toolic (Bishop)
on Jan 20, 2017 at 15:33 UTC ( #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? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2022-01-24 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (65 votes). Check out past polls.

    Notices?