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

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?

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 exploiting the Monastery: (4)
As of 2015-11-27 07:33 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (719 votes), past polls