in reply to Re: Re^3: Determining the true type of a reference
in thread Determining the true type of a reference

Now, tell me why you would do the vile, evil thing you did.

:-)

I might do it when you have an object that can usefully be treated as another perl type. For example consider an class like this:

my $account = Account->new(; $account->add_transaction(30, 'food')->add_transaction(3, 'comics') ->add_transaction(99, 'food'); # get the second transaction my $transaction = $account->[1]; # get all the food transactions my $array_ref = $account->{food};

I freely admit there are other APIs that would allow you to do the same thing. You could also implement the above with tie instead of overloading. However, overloading is not a totally insane solution if you just need read access.