I have a question about how the left and right sides of the operator are evaluated -> . Consider the following code:
#! /usr/bin/perl use strict; use warnings; use feature ':5.10'; $, = ': '; $" = ', '; my $sub = sub { "@_" }; sub u { shift->(@_) } sub v { my $s = shift; $s->(@_) } say 'u', u($sub, 'foo', 'bar'); say 'v', v($sub, 'foo', 'bar');
Output:
u: CODE(0x324718), foo, bar v: foo, bar
I expect u and v to behave the same, but they do not. I always assumed that perl rated things from left to right in these situations. Code like shift->another_method(@_) and even shift->another_method(shift, 'stuff', @_) pretty common.
Why is this interrupted if the first argument is a code reference? Am I on undefined / undocumented territory here?
perl
user3688180
source share