in reply to What is %:: used for?

If you have a module and want to put subs or vars in main, you can use export.
How do you think export does it? By direct symbol table access, accessing things like %:: and %CGI:: and so on!

If you're merely watching the play, don't wander around backstage, please. {grin}

-- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re: •Re: What is %:: used for?
by Juerd (Abbot) on Jun 14, 2002 at 13:55 UTC

    How do you think export does it? By direct symbol table access, accessing things like %:: and %CGI:: and so on!

    While Exporter does access the symbol table directly by using typeglobs, it doesn't use any hash ending in ::. This is probably because it exports symbols, not symbol tables.

    I searched both Exporter.pm and Exporter::Heavy.pm. The only reference to something ending in :: was:

    Carp::croak("$_[0]Illegal null symbol in \@${1}::EXPORT") if $_[0] =~ /^Unable to create sub named "(.*?)::"/;
    in Exporter/Heavy.pm.

    - Yes, I reinvent wheels.
    - Spam: Visit eurotraQ.
    

Re: •Re: What is %:: used for?
by SarahM (Monk) on Jun 14, 2002 at 12:51 UTC
    Is export written in perl? I would have thought that export was written in the c code that makes up perl! But if export is written in perl, I can definitely see the use of %::.
      Yes it's in Perl! See perldoc -m Exporter, but don't stare at it too hard before you're ready to understand and respect the smoke and mirrors revealed.

      -- Randal L. Schwartz, Perl hacker

        Thanks, it's definitely more complex then anything I've written...but it's not that bad to follow, you just need to understand typeglobs and the system table structure.
Re: •Re: What is %:: used for?
by cybear (Monk) on Jun 14, 2002 at 14:28 UTC
    If you're merely watching the play, don't wander around backstage, please. {grin}

    Uncalled for... Bad form, old boy.

      Which part of "{grin}" don't you understand?
        Bareword "grin" not allowed while "strict subs"
        Its use to play down an otherwise condescending and unnecessary statement, perhaps?