in reply to Re^10 : mod_perl and cache?
in thread mod_perl and cache?

The tie command does not return a reference to the hash that you tied; it returns a reference to an object of the class that you tied it to which you can throw away unless you need it to call extended methods or something. The tie mechanism is meant to be completely transparent to other code that wants to treat the tied variable like a normal variable, and is tracked internally, not through blessing/isa. To determine if a variable is tied, use the tied command.

Replies are listed 'Best First'.
Re: checking if a variable is tied or not
by Flame (Deacon) on Mar 03, 2003 at 23:08 UTC
    I have written a module (for my own use) that uses tie before, so I understand it, and OOP. I was using ref(tied %hash) to demonstrate that it is not returning an object, meaning it is no longer tied.



    My code doesn't have bugs, it just develops random features.

    Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)

      You copied everything out of the tied hash %temp into the non-tied hash %hash and then tested that. Here is a version of your code that demonstrated that it is still tied:
      use Tie::IxHash; use strict; use warnings; { my %hash; print ref(tie(%hash, "Tie::IxHash"))."\n"; $hash{'hi'} = 1; $hash{'there'} = 2; some(\%hash); } sub some{ my $temp = shift; print ref($temp)."\n"; # my %hash = %{$temp}; # print ref(tied(%hash)); print ref(tied(%{$temp})); }
        Yay! It works! Thank you for your patience. I'm still kinda clueless when it comes to mod_perl, but I'm trying.

        Thanks!



        My code doesn't have bugs, it just develops random features.

        Flame ~ Lead Programmer: GMS (DOWN) | GMS (DOWN)