in reply to Constant code
When you call a sub() in an expression, the paren's are normally required. There are built in functions and ways to make a user defined function work like a built in function with prototypes.
The simple answer here is to call sub1() and sub2() with no arguments, use sub1(), etc. Don't use a bare word sub name for a normal user defined sub/function.
#!usr/bin/perl use strict; use warnings; sub sub1{return 2} sub sub2{return 2} my ($a, $b) = (sub1, sub2); my ($s, $t) = ((2*sub1()+sub2()), (2*$a+$b)); say STDERR "$a==", sub1; say STDERR "$b==", sub2; say STDERR "$s==$t"; __END__ 2==2 2==2 6==6
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Constant code
by Anonymous Monk on Jan 20, 2017 at 21:00 UTC | |
by Anonymous Monk on Jan 20, 2017 at 22:15 UTC | |
by mpersico (Monk) on Jan 20, 2017 at 21:02 UTC | |
by AnomalousMonk (Archbishop) on Jan 20, 2017 at 23:04 UTC |