in reply to Re^2: How to trick strict like Exporter does
in thread How to trick strict like Exporter does

The difference is that a glob assignment doesn't set the "this has been imported" bit unless the importing is done via code that was compiled into a different package. See Re: How does strict determine if something is legally declared? (import) for more.

- tye        

  • Comment on Re^3: How to trick strict like Exporter does (import)

Replies are listed 'Best First'.
Re^4: How to trick strict like Exporter does (import)
by rblasch (Monk) on Jul 12, 2006 at 16:16 UTC

    Just for reference, here's a comparison of the internals. Note the additional IMPORT( SV ) in FLAGS.

    With package imp;.
    C:\>perl -MDevel::Peek -e "BEGIN { require 'imp.pl'}; print Dump(*foo) +" SV = PVGV(0x1950c74) at 0x195aa84 REFCNT = 2 FLAGS = (GMG,SMG,MULTI,IN_PAD,IMPORT( SV )) IV = 0 NV = 0 MAGIC = 0x193716c MG_VIRTUAL = &PL_vtbl_glob MG_TYPE = PERL_MAGIC_glob(*) MG_OBJ = 0x195aa84 NAME = "foo" NAMELEN = 3 GvSTASH = 0x2260dc "main" GP = 0x1950cc4 SV = 0x19307cc REFCNT = 1 IO = 0x0 FORM = 0x0 AV = 0x0 HV = 0x0 CV = 0x0 CVGEN = 0x0 GPFLAGS = 0x0 LINE = 2 FILE = "imp.pl" FLAGS = 0x1a EGV = 0x195aa84 "foo"
    Without package imp;.
    C:\>perl -MDevel::Peek -e "BEGIN { require 'imp.pl'}; print Dump(*foo) +" SV = PVGV(0x195064c) at 0x1930730 REFCNT = 2 FLAGS = (GMG,SMG,MULTI,IN_PAD) IV = 0 NV = 0 MAGIC = 0x1959054 MG_VIRTUAL = &PL_vtbl_glob MG_TYPE = PERL_MAGIC_glob(*) MG_OBJ = 0x1930730 NAME = "foo" NAMELEN = 3 GvSTASH = 0x2260dc "main" GP = 0x195ecf4 SV = 0x19307cc REFCNT = 1 IO = 0x0 FORM = 0x0 AV = 0x0 HV = 0x0 CV = 0x0 CVGEN = 0x0 GPFLAGS = 0x0 LINE = 1 FILE = "imp.pl" FLAGS = 0xa EGV = 0x1930730 "foo"
Re^4: How to trick strict like Exporter does (import)
by betterworld (Curate) on Jul 12, 2006 at 17:44 UTC
    Thank you for that link, it describes exactly my problem. Well, apparently I have to accept this as "the way perl does things", even though I fail to see why it's sensible.