My guess is that it isn't possible (or a really good idea)
for the simple reason that Values can be called by more
than one Name. There is *not* a 1 to 1 relationship between them. At least in the untied world, it would be quite cumbersome to make sure Values always new exactly what Names were refering to them. Consider the following
code:
#!/usr/bin/perl -wT
use strict;
my $x = {name => 'x', value => 123};
my $y = $x;
$y->{name} = 'y';
$y->{value} = 321;
print "X: $x->{name} => $x->{value}\n";
print "Y: $y->{name} => $y->{value}\n";
=output
X: y => 321
Y: y => 321
Here we have the *names* 'x' and 'y' pointing to the same value.. It doesn't make sense in this instance for the value to know what its name is, because it has more than one (could have used an anon hash, in which case it would have no Name at all).
In general I think its a bad idea to attempt to replicate the name of the variable in the contents of the variable. However, I haven't done much Tie:: development (used them a bunch, but haven't spent much time under the hood) so take my advice in the more general sense.
-Blake
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.