Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: How can I create an anonymous scalar?

by PrakashK (Pilgrim)
on Jul 26, 2001 at 18:19 UTC ( #99984=note: print w/ replies, xml ) Need Help??


in reply to How can I create an anonymous scalar?

I am confused. Do you really want an anonymous scalar?

You want to have several references to a scalar and also to be able to change the value of the scalar independently (not via the references). If so, you need to name that scalar with a scalar variable and it won't be anonymous.

Anyway, what's wrong with a straight reference to a scalar?

$v = "something"; $ref1 = \$v; $ref2 = \$v; # both $ref1 and $ref2 point to the same variable. # change the value $v = "something else"; # both $ref1 and $ref2 will point to the change +d value $v2 = "new value"; $ref1 = \v2; # $ref2 now points to a new variable # $ref2 will continue to point to $v
Have I totally misunderstood your question?


Comment on Re: How can I create an anonymous scalar?
Download Code
Re: Re: How can I create an anonymous scalar?
by Anonymous Monk on Jul 27, 2001 at 10:21 UTC
    Well, just a bit. I didn't want to change $$ref1 (and $$ref2) if I changed $v. The answer from Randal Schwartz (merlyn) is what I was looking for. Thanks anyway!

    --
    Alex

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (19)
As of 2014-07-10 13:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (210 votes), past polls