Re: Trouble with variable scoping



John Moon wrote:
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 qw(@excludedIPAddresses);

No, no you don't. For one, that's a syntax error, as there is no such
keyword 'Use'. For two, the vars pragma has been obsoleted by the our
keyword. And for three, there's no reason to make this a global
variable.

Paul Lalli

.



Relevant Pages

  • Re: Why not auto?
    ... auto keyword can not be used to ... >>> declare formal parameter. ... >> No storage class specifier except register can be used for function ... The keyword "static" is the factotum of the C Standard, ...
    (comp.lang.c)
  • Re: Simple Managed DLL Creation
    ... I'm only somewhat familiar with the "static" keyword. ... I understand that if I declare a VARIABLE static, ... > Use static members of a class instead. ... > Ronald Laeremans ...
    (microsoft.public.dotnet.languages.vc)
  • Re: Random Number Function
    ... > doing a batch update to the table from MS Access, ... > DECLARE @RandomNumber DOUBLE ... > Incorrect syntax near the keyword 'SET'. ...
    (microsoft.public.sqlserver.programming)
  • Re: static extern?
    ... >> much sense to declare it as extern in the header. ... I think they didn't want to introduce a new keyword. ... actionally the meaning that static has within a class definition is the ...
    (comp.lang.cpp)
  • Re: pl1gcc-0.0.11 released
    ... the index variable of while is a keyword and =b is an expression, ... 2 dcl fixed; ... is an external entry, it must be declared by a DECLARE ...
    (comp.lang.pl1)