The stupid question is the question not asked | |
PerlMonks |
Re: Help needed understanding global variables in Perlby rinceWind (Monsignor) |
on Mar 05, 2002 at 09:19 UTC ( [id://149309]=note: print w/replies, xml ) | Need Help?? |
Dear Anonymous Monk, you have a number of questions rolled into your query. My first piece of advice is to read perlsub in the core documentation, if you have not already done so. Why do you need global variables? You rarely need them in C. If you are wanting to preserve state information between subroutine calls, you should look at using a class, see perltoot object tutorial, or a closure, see Funkyness with closures.... Also, if the declaration of the sub is inside a block, it has access to 'my' variables declared in the block before the sub, which will keep their value between calls. Hope this helps and I haven't confused you too much --rW
In Section
Seekers of Perl Wisdom
|
|