Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: ref == "REF"

by Prior Nacre V (Hermit)
on Oct 18, 2004 at 10:25 UTC ( #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? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2022-05-18 12:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (70 votes). Check out past polls.

    Notices?