On Apr 9, 2008, at 19:30, <[EMAIL PROTECTED]> <[EMAIL PROTECTED] > wrote:
Hi,
Assuming my script use a strict pragma.
If I have a lexical variable declared inside a sub routine and I wish to globalize this lexical variable, what are the various options to globalise this variable?

Thanks

###############
use strict;
use warnings;

testing();

sub testing {
   my $variable = 2;
   print "I can see you Mr $variable\n";
}

print "So what are the various options to globalise this \$variable which is $variable\n";

You don't. The testing function should return the value and the caller should catch it in another lexical variable. Global variables are rarely the right answer to a problem. What exactly are you trying to solve with a global variable?

--
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to