Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: ref == "REF"

by adamk (Chaplain)
on Oct 19, 2004 at 01:53 UTC ( [id://400382]=note: print w/replies, xml ) Need Help??


in reply to ref == "REF"

I'm not sure what everyone is so confused about...

A SCALAR is a reference to a scalar.
A REF is a reference to a reference.

A SCALAR is a reference to data.
A REF is a reference to a pointer (of sorts).

Personally, I use it all time for writing Decorator classes.

Go take a look at Object::Destroyer in CPAN, it wraps around another object containing circular references and makes sure it gets destroyed normally.

my $Destroyer = bless \$Object, 'Object::Destroyer';

So if you Scalar::Util::reftype $Destroyer, you get 'REF'. Which is as it should be because unlike $Object, which could be B<anything> of any type, $Destroyer just points directory to the object it is Decorating

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://400382]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2024-03-28 23:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found