Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: 2 questions about anonymous storage and global variables

by Enlil (Parson)
on Jan 13, 2006 at 01:04 UTC ( [id://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

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://522853]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-26 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found