in reply to Re: "possible typo" warnings in modules
in thread "possible typo" warnings in modules

For this particular warning, "in-module" means the path to it is absolute, it has /lib/ in in somewhere or the name has a .pm in it. I don't think you can really abstract the idea of "in module" elsewhere. This was a pretty specific bit of code.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

  • Comment on Re^2: "possible typo" warnings in modules

Replies are listed 'Best First'.
Re^3: "possible typo" warnings in modules
by almut (Canon) on Feb 17, 2007 at 23:08 UTC

    Thanks again.   I actually looked it up in the sources now (guess I should've done so earlier), and I presume it's this part in Perl_gv_check(), gv.c:1251:

    /* performance hack: if filename is absolute and it's a standa +rd * module, don't bother warning */ #ifdef MACOS_TRADITIONAL # define LIB_COMPONENT ":lib:" #else # define LIB_COMPONENT "/lib/" #endif if (file && PERL_FILE_IS_ABSOLUTE(file) && (instr(file, LIB_COMPONENT) || instr(file, ".pm"))) { continue; } CopLINE_set(PL_curcop, GvLINE(gv)); #ifdef USE_ITHREADS CopFILE(PL_curcop) = (char *)file; /* set for warning */ #else CopFILEGV(PL_curcop) = gv_fetchfile(file); #endif Perl_warner(aTHX_ packWARN(WARN_ONCE), "Name \"%s::%s\" used only once: possible typo", HvNAME_get(stash), GvNAME(gv)); ... with PERL_FILE_IS_ABSOLUTE being defined as (for my platform): #define PERL_FILE_IS_ABSOLUTE(f) (*(f) == '/')

    So, I removed the .pm extension (the other two criteria, i.e. /lib/ and absolute path, don't apply in my case -- I even checked with strace(1) what it's really loading). (Update: actually, taking a closer look, I see it's PERL_FILE_IS_ABSOLUTE(file) && ..., so the other two shouldn't apply anyway...)

    Interestingly, still none of the following do issue the warning:

    require "WarnMe"; --- do "WarnMe"; --- my $code = join '', <DATA>; eval $code; __DATA__ my $val = $Some::Nonexistent::Pkg::variable; --- eval 'my $val = $Some::Nonexistent::Pkg::variable';

    Well, I guess some other hack is playing tricks on me...   Anyway. :)