|We don't bite newbies here... much|
Re: Perl array declaringby shmem (Canon)
|on Jun 01, 2013 at 22:34 UTC||Need Help??|
A variable (a symbol which lets you reference some data) in perl is ruled by two constraints, or boundaries, or scopes:
Package scoped variables are recorded in the symbol table of their associated namespace.
Lexical scoped variables are visible only in the current BLOCK, file or eval.
The package variables are either just written without any declaration (e.g $file = "myfile.txt"; - the strict pragma forbids that), used fully qualified (e.g. $main::file = "myfile.txt"; (that is ok under strict) or declared with our (e.g. our $file = "myfile.txt";). The our creates a symbol table entry for a variable declared that way and a lexical alias for that symbol.
The lexical variables are declared with my (e.g. my $file = "myfile.txt";). At runtime, they are reset when their scope is entered.
Just for completeness - a package variable can be used in a lexical sort of way, too - masking the original symbol table variable slot with a local declaration. They are valid during the execution time in the current scope, even branching to different files.
Phew. Now back to your question:
Hello i am a new to Perl and i am trying to understand what is differences between declare :my @array or @arry?
If anything of the above is unclear, just ask again.