Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Exporter. Correct way to override import?

by dave_the_m (Monsignor)
on May 04, 2018 at 22:45 UTC ( #1214081=note: print w/replies, xml ) Need Help??


in reply to Exporter. Correct way to override import?

Replace
my $this = shift ; $this->SUPER::import( @_ ) ;
with:
Foo->export_to_level(1, @_);
By default, Export::import() adds symbols to its caller's namespace, so it's been adding them to Foo:: rather than main::.

You have to explicitly tell Exporter to export more than 1 level up.

See the section in Exporter's docs, 'Exporting Without Using Exporter's import Method'

Dave.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1214081]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2019-05-21 11:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (132 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!