in reply to Debating With Friends
Result is that it gives is "equal". Why?
Because eq is a function with infix syntax. That is: a eq b is actually eq( a, b ).
Thus, by the time eq() sees the parameters, both assignments have been done, and it just gets two copies of the (same) final value.
Viz
sub eq{ print "@_"; $_[0] eq $_[1] };; print eq( $x=1, $x=2 );; Ambiguous call resolved as CORE::eq(), qualify as such or use & at (ev +al 13) line 1, <STDIN> line 5. Use of uninitialized value $_ in print at (eval 13) line 1, <STDIN> li +ne 5. print &eq( $x=1, $x=2 );; 2 2 1
|
---|