develooper Front page | perl.perl5.porters | Postings from February 2019

[perl #133823] strict does not ban all barewords

Thread Previous | Thread Next
From:
Tony Cook via RT
Date:
February 5, 2019 05:09
Subject:
[perl #133823] strict does not ban all barewords
Message ID:
rt-4.0.24-27839-1549343384-1634.133823-15-0@perl.org
On Mon, 04 Feb 2019 15:16:24 -0800, wagnerc@plebeian.com wrote:
> Using the strict pragma does not ban all usages of barewords or force 
> them to resolution as subroutines so that they can fail as an undefined 
> subroutine.
> 
> Tested on Perl 5.22.4 and 5.29.8
> 
> Examples:
> $ perl -MO=Deparse,-p,-q,-x20,-P -e 'use strict; print "$^X $^V\n"; my 
> $string; print split FOO, $string; '
> use strict;
> print(((($^X . ' ') . $^V) . "\n"));
> my($string);
> print(split(/FOO/, $string, 0));
> -e syntax OK
> 
> 
> 
> $ perl -MO=Deparse,-p,-q,-x20,-P -e 'use strict; print "$^X $^V\n"; my 
> @list; print sort FOO @list; '
> use strict;
> print(((($^X . ' ') . $^V) . "\n"));
> my(@list);
> print((sort FOO @list));
> -e syntax OK

split is fixed by my patch in #133822.

sort specially allows for a bareword subname for the sort sub and dies at runtime if the sub named doesn't exist, even if the sub doesn't need to be called:

 $ ./perl -Ilib -e 'use strict; my @list; print sort FOO @list; '
 Undefined sort subroutine "main::FOO" called at -e line 1.

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=133823

Thread Previous | 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