Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Creating flexible method accessor

by puterboy (Scribe)
on Feb 02, 2014 at 04:13 UTC ( #1073029=note: print w/ replies, xml ) Need Help??


in reply to Creating flexible method accessor

One other question..
I would like to define this subroutine in a package and then run the routine from other packages where I actually want the actual accessors to live. However, it seems that the mk_accessor routine creates all the accessors in the name-space of the package where the mk_accessor subroutine is defined rather than the one where it is run.

Is there any easy/clean way to have the accessor subroutines created in the namespace of the package where mk_accessor is run?


Comment on Re: Creating flexible method accessor
Replies are listed 'Best First'.
Re^2: Creating flexible method accessor
by Anonymous Monk on Feb 02, 2014 at 04:24 UTC

    Sub::Install (recommended) or:

    my ($caller_package) = caller; ... no strict 'refs'; *{"${caller_package}::$name"} = $accessor;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (15)
As of 2015-07-31 16:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (279 votes), past polls