in reply to Re: How can I unbless an object?
in thread How can I unbless an object?

It's never occured to me untill now, but i can definitely think of some cases where you may have blessed a refrence for use in some code (ie: doing OO) but when passing the ref to other code which drives it's behavior by the ref type of it's arg, you may want it to be treated as the underlying hash that it is.

I don't know if "curse" is really the right term for the case I'm thinking of (where you don't want to change the ref itself, you just wan a new ref to the same object with a different type ... which strikes me as being almost like a "cast" method...

my $foo = new Foo; my $hash = cast 'HASH', $foo; print ref $hash; # 'HASH'

Replies are listed 'Best First'.
•Re: Re: Re: How can I unbless an object?
by merlyn (Sage) on Jul 19, 2002 at 18:15 UTC
    but i can definitely think of some cases where you may have blessed a refrence for use in some code (ie: doing OO) but when passing the ref to other code which drives it's behavior by the ref type of it's arg, you may want it to be treated as the underlying hash that it is.
    And all I can think of when I think of that is "bad design".

    -- Randal L. Schwartz, Perl hacker

Re^3: How can I unbless an object?
by ml340k (Novice) on Aug 16, 2017 at 15:25 UTC
    use Scalar::Util qw(reftype);

    using reftype instead of ref allows hash checking of an object from any class