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
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
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/
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
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
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
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
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
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
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
10 matches
Mail list logo