Granted, the Tie::IxHash documentation isn't quite clear on this, but the point of Perl's tie interface is to provide variables that look like regular variables from the outside, but can act differently. Tie::IxHash mostly behaves like a regular hash, except that it remembers the order of keys. So perhaps it's easiest to just do the following?
use Tie::IxHash; tie my %hash, 'Tie::IxHash', one => 1, two => 2; print "$hash{two}\n"; # prints "2"
Update: Another thing the documentation doesn't seem to mention is that you can use both interfaces, via tied:
use Data::Dump; dd tied(%hash)->Indices(qw/two one/); # prints (1, 0)
In reply to Re: Retrieving a single value from a Tie::IxHash object (updated)
by haukex
in thread Retrieving a single value from a Tie::IxHash object
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |