in reply to Re: Puzzling $| behavior
in thread Puzzling $| behavior
(please correct here me if I'm wrong)I don't know if perl's documentation defines (as a feature) the order in which arguments are evaluated, but it's simple to check that it really does evaluate them in left-to-right order:
The reason the OP's example is weird is because Perl's argument passing uses aliases whenever possible (as ikegami illustrates below). In the example, an alias to $| gets passed as the second argument. When evaluating the fourth argument, $| is changed. When print finally inspects its arguments, the aliased second argument will report the changed value.$ perl -le 'print sub{print 1; "x"}->(), sub{print 2; "y"}->()' 1 2 xy
blokhead
In Section
Seekers of Perl Wisdom