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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Puzzling $| behavior
by ikegami (Patriarch) on Oct 08, 2007 at 05:54 UTC | |
by mwah (Hermit) on Oct 08, 2007 at 10:35 UTC | |
by oha (Friar) on Oct 08, 2007 at 12:34 UTC | |
by ikegami (Patriarch) on Oct 08, 2007 at 16:58 UTC |