CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [FishMonger] using package in perl: Edit Log



budman
User

Feb 12, 2012, 8:59 AM


Views: 6333
Re: [FishMonger] using package in perl

Hi

Trying to understand why its called File scope.
Is 'my' making it static?

This is how I understand scoping

Code
my $name = "ABC";  # program or global scope 
{
my $name = "ABC"; # file scope (static) cannot be changed once set
sub static_name { $name }
}

sub {
my $name = "XYZ"; # function scope
for (@x) {
my $name = "123"; # block scope
}
}



Edit: I did some searching on scopes, I see now what you mean.
The my $name in the beginning has "til end of file" scope.
http://perl.plover.com/FAQs/Namespaces.html

Thanks
Rich


(This post was edited by budman on Feb 12, 2012, 9:20 AM)


Edit Log:
Post edited by budman (User) on Feb 12, 2012, 8:59 AM
Post edited by budman (User) on Feb 12, 2012, 9:02 AM
Post edited by budman (User) on Feb 12, 2012, 9:20 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives