in reply to lexical variable
In this context it means that the variable is valid up to the end of the scope it is declared it. If you declare it at the top of the file, it's known in all of the file. If you declare it within a function or a block, it's only known in that function/block and in inner blocks of that block.
Package variables, in contrast, can also be accessed from other files.
It makes sense to declare all of your variables and use strict;. That way Perl will find typos in variables for you that otherwise take hours to find.
Update: we've had quite a few discussions and tutorials about scoping already, maybe you find some of them enlightening:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: lexical variable
by manishrathi (Beadle) on Oct 06, 2009 at 15:50 UTC | |
by moritz (Cardinal) on Oct 06, 2009 at 16:44 UTC |