in reply to Variable Scope
If I understand correctly, you can make the variable global by adding :: after the $,@, or whatever. If you do so you will not be able to scope it using my, so you can initialze it at your leisure. For example:
Hope this helps,
--- perchance
#!/usr/bin/perl -w use strict; $::var = 0; print "Variable is [$::var]\n"; changeVar(); print "Variable is now [$::var]\n"; sub changeVar { $::var = 2; }
Hope this helps,
--- perchance
|
---|
Replies are listed 'Best First'. | |
---|---|
NEVER do this. Ever. Not even once.
by dragonchild (Archbishop) on Jul 30, 2001 at 18:24 UTC | |
by bikeNomad (Priest) on Jul 30, 2001 at 20:59 UTC | |
by dragonchild (Archbishop) on Jul 31, 2001 at 16:29 UTC | |
by perchance (Monk) on Jul 30, 2001 at 18:45 UTC | |
by chromatic (Archbishop) on Jul 31, 2001 at 04:02 UTC |
In Section
Seekers of Perl Wisdom