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?

Comment on Re: Creating flexible method accessor
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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2015-02-27 00:47 GMT
Find Nodes?
    Voting Booth?

    On my keyboard, Caps lock is:

    Results (437 votes), past polls