Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Change to package name handling in Perl 5.18?

by tobyink (Canon)
on Sep 15, 2020 at 19:23 UTC ( #11121810=perlquestion: print w/replies, xml ) Need Help??

tobyink has asked for the wisdom of the Perl Monks concerning the following question:

Try this on an old version of Perl (before 5.17) and a newer one (5.18 or above):

perl -MHTTP::Tiny -e'my $class = q(::HTTP::Tiny); $class->new'

Was this change documented anywhere?

Replies are listed 'Best First'.
Re: Change to package name handling in Perl 5.18?
by haukex (Bishop) on Sep 15, 2020 at 20:30 UTC
    ./Porting/bisect.pl --target=miniperl --start=v5.16.3 --end=v5.18.0 --expect-fail -e 'sub foo::new {} "::foo"->new'
    ...
    
    commit 7156e69abfd37267e85105c6ec0c449ce4e41523
    Author: Father Chrysostomos <sprout@cpan.org>
    Date:   Thu Sep 20 08:56:38 2012 -0700
    
        [perl #105922] Allow any string before ->meth
        
        The rules for filtering out what do not look like package names are
        not logical and disallow valid things like "::main", while allowing
        q"_#@*$!@*^(".
        
        This commit simply lets any non-empty string be used as a package
        name.  If it is a typo, you’ll get an error anyway.  This allows
        autobox-style calls like "3foo"->CORE::uc, or even "3foo"->uc if you
        set up @ISA first.
        
        I made an exception for the empty string because it messes up caches
        somehow and causes subsequent method calls all to be called on the
        main package.  I haven’t looked into that yet.  I don’t know whether
        it’s worth it.
        
        The changes to the tests in cpan/Test-Simple have been submit-
        ted upstream.
    

    Mentioned in perl5180delta:

    Class method calls are now allowed on any string, and not just strings beginning with an alphanumeric character. [perl #105922]

      Ah. I should have been searching for "class" instead of "package". Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://11121810]
Approved by davies
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2020-09-20 08:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I don’t succeed, I …










    Results (120 votes). Check out past polls.

    Notices?