in reply to Perl keywords for declaring variables: my, our and local???
Results are:#!/usr/bin/perl our $a = "foo"; print "$a\n"; package Our; print "$Our::a <--shouldn't print anything here\n"; print "$main::a <--should print 'a' from the main symbol table here\n" +; print "$a <--should also print 'a' from the main symbol table he +re\n\t\tdue to lexically scoped alias\n";
By default any global variables you create automatically populate the "main" symbol table, %main::. With a package declaration you could change which symbol table you are populating when you declare unqualified variables.foo <--shouldn't print anything here foo <--should print 'a' from the main symbol table here foo <--should also print 'a' from the main symbol table here due to lexically scoped alias
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Perl keywords for declaring variables: my, our and local???
by demerphq (Chancellor) on Mar 23, 2003 at 10:07 UTC |