The subs pragma is a red herring. Remove it, and the problem still holds.
Quite so. If I'm not mistaken, moving the definition of the non_commutative sub to the end of the script *does* create a purpose for loading the 'subs' pragma iff we want to avoid the use of parens - and it would have been better if the scripts I had presented did precisely that:
use warnings;
use subs qw(non_commutative); #necessary
$x = 10 * non_commutative;
$y = non_commutative * 10;
print "$x\n$y\n\n";
$x = 10 + non_commutative;
$y = non_commutative + 10;
print "$x\n$y\n";
sub non_commutative {return 17}
__END__
Outputs:
170
17
27
17
and
use warnings;
use subs qw(non_commutative); #unnecessary
$x = 10 * non_commutative();
$y = non_commutative() * 10;
print "$x\n$y\n\n";
$x = 10 + non_commutative();
$y = non_commutative() + 10;
print "$x\n$y\n";
sub non_commutative {return 17}
__END__
Outputs:
170
170
27
27
Cheers, Rob |