i knw if i want a private variable i can write:
but what if i want a variable to be availabel through-out a script?Code:my $cat = "cat";
Printable View
i knw if i want a private variable i can write:
but what if i want a variable to be availabel through-out a script?Code:my $cat = "cat";
Scope it a "file level" (right at the top of your script, before any functions, etc) which puts it in the default "main" package. Else look into the Perl doc about the our keyword.
thanks, but while looking at the "our" scope i found the "local" scope... can anyone telling the difference b/c the documentation is unclear on this point
ps: anyone know any good perl tutorials\books\references on-line?
i've got the ActiveState documentation that came with my perl interpreter and the "picking up PERL" pdf which is quite basic to say the least...
Changes are you want to stick with "my" unless you're working with your own packages. Basically, local is used within a function to decalre a variable with the same name as a global one with the function, but functions called from within the function don't get the global variable. I think local will probably be obsoleted sometime.