RE: Trouble with variable scoping

2006-09-01 Thread Roman Daszczyszak
From: Charles K. Clarkson [EMAIL PROTECTED] To: beginners@perl.org Date: Thu, 31 Aug 2006 10:41:33 -0500 Subject: RE: Trouble with variable scoping Roman Daszczyszak wrote: : In my perl script, I have a global variable called : @excludedIPAddresses, declared at the top of the script using : my

Re: Trouble with variable scoping

2006-09-01 Thread John W. Krahn
Roman Daszczyszak wrote: What is the scope of a variable that is declared at the top of a file using 'my'? I had thought that this would just make a variable that is scoped to the entire file, yet 'local' does not localize the variable in a subroutine, even though it (local) according

Re: Trouble with variable scoping

2006-09-01 Thread Dr.Ruud
Moon, John schreef: Maybe you want.. Use vars qw(@excludedIPAddresses); s/Use/use/, but: use vars has been antiquated by our(). -- Affijn, Ruud Gewoon is een tijger. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

Trouble with variable scoping

2006-08-31 Thread Roman Daszczyszak
In my perl script, I have a global variable called @excludedIPAddresses, declared at the top of the script using my: use strict; use warnings; use Net::Ping; use Net::Netmask; use Net::NBName; use DBM::Deep; # User-configured variable declarations my

RE: Trouble with variable scoping

2006-08-31 Thread Moon, John
When I run this, I get an error Can't localize lexical variable. I understand that it's because the variable is declared using my; what I don't understand is why, or what I should declare the variable as, since if I leave out my I get an error using use strict. Maybe you want.. Use vars

RE: Trouble with variable scoping

2006-08-31 Thread Charles K. Clarkson
Roman Daszczyszak wrote: : In my perl script, I have a global variable called : @excludedIPAddresses, declared at the top of the script using : my. That sounds like a bad idea, but go on. : When I run this, I get an error Can't localize lexical : variable. I understand that it's because

Re: Trouble with variable scoping

2006-08-31 Thread Mumia W.
On 08/31/2006 08:19 AM, Roman Daszczyszak wrote: In my perl script, I have a global variable called @excludedIPAddresses, [...] my @excludedIPAddresses = qw# 192.168.0.142 192.168.3.118 #;# [...] local @excludedIPAddresses = @excludedIPAddresses; [...] When I run this, I get an error

Re: Trouble with variable scoping

2006-08-31 Thread Randy W. Sims
Roman Daszczyszak wrote: In my perl script, I have a global variable called @excludedIPAddresses, declared at the top of the script using my: [...] When I run this, I get an error Can't localize lexical variable. I understand that it's because the variable is declared using my; what I don't

Re: Trouble with variable scoping

2006-08-31 Thread John W. Krahn
Randy W. Sims wrote: Roman Daszczyszak wrote: In my perl script, I have a global variable called @excludedIPAddresses, declared at the top of the script using my: [...] When I run this, I get an error Can't localize lexical variable. I understand that it's because the variable is declared

Re: Trouble with variable scoping

2006-08-31 Thread Randy W. Sims
John W. Krahn wrote: Randy W. Sims wrote: Roman Daszczyszak wrote: In my perl script, I have a global variable called @excludedIPAddresses, declared at the top of the script using my: [...] When I run this, I get an error Can't localize lexical variable. I understand that it's because the