in reply to The mystery of $->[1]
G'day hurricup,
++ Good catch!
The code itself parses as legal Perl:
$ perl -MO=Deparse,-p -e 'my $l = ref $a eq "ARRAY" ? ($a->[0] || $->[ +1]) : $a;' (my $l = ((ref($a) eq 'ARRAY') ? ($a->[0] || ($- > [1])) : $a)); -e syntax OK
And, as you can see, your analysis is correct: '$-' is being compared with '[1]'.
There's actually two adjacent lines like that in the source code:
# Deal with the case of an item actually being an array ref to 1 o +r 2 # hashrefs. Don't assign to $a or $b, as they're aliases to the or +ignal my $l = ref $a eq 'ARRAY' ? ($a->[0] || $->[1]) : $a; my $r = ref $b eq 'ARRAY' ? ($b->[0] || $->[1]) : $b;
I suspect those should be:
my $l = ref $a eq 'ARRAY' ? ($a->[0] || $a->[1]) : $a; my $r = ref $b eq 'ARRAY' ? ($b->[0] || $b->[1]) : $b;
although, I haven't delved deeply enough into the code to say for certain.
I suggest you raise a bug report for this.
-- Ken
In Section
Seekers of Perl Wisdom