Re: Trouble with variable scoping
- From: mumia.w.18.spam+nospam@xxxxxxxxxxxxx (Mumia W.)
- Date: Thu, 31 Aug 2006 10:39:07 -0500
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 "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".
Declare it using 'our':
our @excludedIPAddresses;
.
- References:
- Trouble with variable scoping
- From: Roman Daszczyszak
- Trouble with variable scoping
- Prev by Date: Re: Reading whole file with while(INPUT) but I need to access each line
- Next by Date: RE: Trouble with variable scoping
- Previous by thread: Re: Trouble with variable scoping
- Next by thread: RE: Trouble with variable scoping
- Index(es):