Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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?


  • 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.


      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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://522853]
[marioroy]: CORE::wait works well eventhough multiple instances or classes using Hobo::Manager.
[Corion]: marioroy: I'm not sure what the normal use for the PID is in P:FM, but I guess that most programs just ignore or log it
[Corion]: Oh, yes, programs could call wait $pid, but if your $pid is an object, then you could add a ->wait method to it and wait $pid would call that automatically "thanks" to indirect object notation
[marioroy]: Just documentation edits is all that remains. Hobo::Simple provides foreach and forseq with identifier capability -- all transparently supporting array, hash, file handle, and seq 1 .. N.
[marioroy]: Corion Regarding PID, that's great. So will leave it so compatible with MCE::Hobo. e.g. ->create returns a Hobo object. Folks can get ->pid from it. So, that's not a problem.
[choroba]: ad readdir: 5.12 needed
[marioroy]: CORE::wait can block if another process reaps a worker from another class. MCE::Hobo takes care of that and transparently.
[Discipulus]: thanks choroba i'll update my answer
[Lady_Aleena]: Hello Discipulus, Corion, choroba, and marioroy...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2017-05-26 08:46 GMT
Find Nodes?
    Voting Booth?