develooper Front page | perl.perl5.porters | Postings from March 2017

[perl #131061] Documentation of backslash operator inducing listcontext for its operand is missing

Thread Next
From:
Håkon Hægland
Date:
March 25, 2017 22:25
Subject:
[perl #131061] Documentation of backslash operator inducing listcontext for its operand is missing
Message ID:
rt-4.0.24-26800-1490480705-1423.131061-75-0@perl.org
# New Ticket Created by  Håkon Hægland 
# Please include the string:  [perl #131061]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=131061 >


I could not find any documentation for the following behavior:

$ perl -E '$s =\sort qw(a b c); say $$s'
c

According to the documentation for sort, the behavior of sort in scalar
context is undefined

$ perl -E '$s = sort qw(a b c); say "undef" if !defined $s'
undef

Apparently when using the backslash operator, sort does not consider
itself to be in scalar context any more, or else the first example should
give an undefined $$s.

I checked the following documentation:

http://perldoc.perl.org/perldata.html#List-value-constructors
http://perldoc.perl.org/perlref.html
http://perldoc.perl.org/perlop.html
http://perldoc.perl.org/functions/sort.html


See also:

http://stackoverflow.com/q/42996519/2173773

Best regards,
Håkon Hægland


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About