Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Accessing name of tied variable in tie constructor

by daxim (Chaplain)
on Jul 10, 2013 at 13:25 UTC ( #1043470=note: print w/replies, xml ) Need Help??

in reply to Accessing name of tied variable in tie constructor

No, not without the usual padwalking trickery.

But Tie::StdHash derived have an identity number (documented as argument named this) which you can use to differentiate between tied variables, see example. I guess that's your real intention.

  • Comment on Re: Accessing name of tied variable in tie constructor

Replies are listed 'Best First'.
Re^2: Accessing name of tied variable in tie constructor
by tobyink (Abbot) on Jul 10, 2013 at 15:04 UTC

    Even PadWalker and Devel::Caller can't help you - TIEHASH doesn't get passed a reference to the tied variable, so there's no chance of it being able to figure out the variable's name.

    Also, the argument this in the Tie::StdHash documentation isn't an identity number; it's a blessed hashref. (It's what most OO Perl code would refer to as $self.)

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043470]
[Corion]: Heh - I just realized, $work management just declared "no raises for anybody this year", and I'm not even angry about that. Even though that implicitly means "raises for the people with an automatic 5% raise in their contract", which the newly-merged ...
[Corion]: ... coworkers have. But I guess I've gone more mellow since I get to relax more, and such stuff doesn't make me as angry as it used to.
[Corion]: $boss will still get to listen to my interpretation :-D
[Eily]: hey, I'm just behind Larry in SioB \o/

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-01-22 11:05 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (233 votes). Check out past polls.