Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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?

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1073029]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2018-06-22 23:11 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (124 votes). Check out past polls.