Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: 2 questions about anonymous storage and global variables

by Enlil (Parson)
on Jan 13, 2006 at 01:04 UTC ( #522853=note: print w/ replies, xml ) Need Help??


in reply to 2 questions about anonymous storage and global variables

Firstly I have a scalar that will contain either a value or a reference to an array. If it's an array I want it to do one thing. If it's a scalar value I want it to do another. What's the correct way of doing this so I don't get errors?

Have a look at ref in the documentation. It has a couple of examples of what you are looking for.

Secondly How can a make a global variable truely global, so that it will be accessible by all packages without using package::variable.

You don't. Well sortof, Can you create *real* global variables?

hth
-enlil


Comment on Re: 2 questions about anonymous storage and global variables
Re^2: 2 questions about anonymous storage and global variables
by cosmicperl (Chaplain) on Jan 13, 2006 at 01:37 UTC
    Thanks that has cleared that up for me. I've read about ref in the past but couldn't for the life of me remember or find on the net. Maybe is should practice some new searching techniques.

      For a basic function like that, perlfunc is often a good place to start when the exact function has slipped your mind.

      -xdg

      Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-12-25 21:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls