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

RFC 'used only once' warnings shouldn't affect (some?) internal packages

Thread Next
From:
Brian Fraser
Date:
May 14, 2013 09:10
Subject:
RFC 'used only once' warnings shouldn't affect (some?) internal packages
Message ID:
CA+nL+nY4bZGs_b=HCm4ONc=j3bfU7a2jPU=-Wrhct0rLk9wvrA@mail.gmail.com
This is annoying:

$ perl -Mwarnings -e 'require Config; if (!$Config::Config{d_foo}) {
*CORE::GLOBAL::glob = sub {} }'
Name "CORE::GLOBAL::glob" used only once: possible typo at -e line 1.
Name "Config::Config" used only once: possible typo at -e line 1.

I'm thinking that anything under %CORE::GLOBAL:: and *Config::Config should
have the MULTI flag automatically set in gv.c, so this warning won't happen
for them. I can provide a patch, but perhaps there's other packages that
should have the same treatment?

Admittedly, Config has a workaround -- change the require to a 'use Config
()' and you're done. But the *CORE::GLOBAL:: doesn't -- you're stuck either
using trickery* or disabling the warning.

[*] My new favorite thing that I'll never have the chance to use: *{ +do {
no warnings "once"; \*CORE::GLOBAL::glob } } = sub {};

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