Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: ref == "REF"

by Prior Nacre V (Hermit)
on Oct 18, 2004 at 10:25 UTC ( [id://400111]=note: print w/replies, xml ) Need Help??


in reply to ref == "REF"

SCALAR is a reference to a scalar; HASH is a reference to a hash; and so on (ARRAY, CODE, ...).

REF is a reference to any of those, e.g.

$ perl -wle 'use strict; my $x = 1; my $y = \$x; my $z = \$y; print "Y +: ", ref($y), " Z: ", ref($z)' Y: SCALAR Z: REF $

I vaguely recall using this feature some time ago when testing some deep copying of a complex data structure although I can't remember the exact details. The basic idea was to continually dereference to a scalar while ref() returned REF (e.g. $deref = $$ref); then to deference to the appropriate datatype (e.g. @array = @$ref if ref($ref) eq 'ARRAY').

I can't provide any help with the internals.

Regards,

PN5

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-05-27 05:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found