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

OK, tyou're right.

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

;-P



Bob Niederman, http://bob-n.com
  • Comment on Re: Re^3: Determining the true type of a reference

Replies are listed 'Best First'.
Re^5: Determining the true type of a reference
by adrianh (Chancellor) on May 26, 2003 at 10:11 UTC
    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.