develooper Front page | perl.perl5.porters | Postings from May 2018

[perl #133178] Sort autoquotes a following bareword under strict

From:
Dan Book
Date:
May 5, 2018 16:19
Subject:
[perl #133178] Sort autoquotes a following bareword under strict
Message ID:
rt-4.0.24-14998-1525537166-181.133178-75-0@perl.org
# New Ticket Created by  Dan Book 
# Please include the string:  [perl #133178]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133178 >


If the first token passed to a sort call is a bareword, and it's not a sort
routine, sort appears to autoquote it, ignoring strict 'subs'.

> perl -E'use strict; say sort bareword'
bareword

> perl -E'use strict; say sort bareword . "bareword"'
barewordbareword

Anything between sort and the bareword makes strict 'subs' work.

> perl -E'use strict; say sort +bareword'
Bareword "bareword" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.

> perl -E'use strict; say sort {$a cmp $b} bareword'
Bareword "bareword" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.

> perl -E'use strict; say sort bareword . bareword'
Bareword "bareword" not allowed while "strict subs" in use at -e line 1.
Execution of -e aborted due to compilation errors.

This behavior should be documented, if not fixed.

-Dan




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