Pearl throws "keys on the link experimental"

Development Environment - OS X 10.10.3, Perl -v

This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail) 

Here is the problem

I migrated the project from the local environment to Windows Server, and now I get the following error:

"on the link are experimental on the CGI / Router.pm 94 line.

module line 94 shows

 my $num_regexes = scalar keys $token_regexes; 

the whole module can be found here https://github.com/kristiannissen/CGIRouter

I create an instance of the router module as follows

 $router->add_route( 'GET', '/home', sub { print header( -type => 'text/html', -charset => 'utf-8' ); print "Hello Pussy"; }); 

I do not have this problem locally, but now when I switch to the production server, I get this problem. From what I can tell, this is related to a specific version of Perl, but before I ask the provider to update Perl, I would like if I can do something to avoid this problem?

+6
source share
1 answer

The documentation for perldoc keys talks about using keys in a hash link:

Starting with Perl 5.14, keys can accept scalar EXPR, which must contain a reference to a useless hash or array. The argument will be dereferenced automatically. This aspect of keys is considered highly experimental. Exact behavior may change in a future version of Perl.

 for (keys $hashref) { ... } 

To avoid the problem, updating Perl will not help. The module must be updated to use the keys in the expected way, instead of using the experimental function. Thus, before calling keys you must dereference hashref.

In particular, change

 my $num_regexes = scalar keys $token_regexes; 

to

 my $num_regexes = scalar keys %$token_regexes; 
+16
source

Source: https://habr.com/ru/post/985086/


All Articles