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));
|
|---|