RE: Trouble with variable scoping
- From: cclarkson@xxxxxxxxxx (Charles K. Clarkson)
- Date: Thu, 31 Aug 2006 10:41:33 -0500
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 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".
Don't use local() in this circumstance.
sub ExcludeIPAddress {
my $ipAddress = shift;
my $subnet = shift;
return scalar grep /$ipAddress/,
@excludedIPAddresses,
$subnet->broadcast(),
$subnet->base();
}
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
Free Market Advocate
Web Programmer
254 968-8328
Don't tread on my bandwidth. Trim your posts.
.
- References:
- Trouble with variable scoping
- From: Roman Daszczyszak
- Trouble with variable scoping
- Prev by Date: Re: Trouble with variable scoping
- Next by Date: RE: [Bulk] RE: Totally lost - need a starting point
- Previous by thread: Re: Trouble with variable scoping
- Next by thread: RE: Trouble with variable scoping
- Index(es):
Relevant Pages
|