@array = reverse;
and
@array = reverse $_;
Both are different. @array = reverse
doesn't use $_
implicitly. We have to declare $_
explicitly. It's a very strange case where $_
is not being used by default. Is it a bug?
As far as I understand from the reverse documentation, reverse
works on arrays, and so it should use @_
rather than the scalar $_
?
The documentation says "Used without arguments in scalar context, reverse()
reverses $_
." [Emphasis added]
$_ = "dlrow ,olleH";
print reverse; # No output, list context
print scalar reverse; # Hello, world