hi,

You may declare my  variables at the outermost scope of a file to hide any such 
identifiers from the world outside that file. This is similar  to C's static variables 
when they are used at the file level. To do this with a subroutine requires the use of 
a closure (an anonymous function that accesses enclosing lexicals). If you want to 
create a private subroutine that cannot be called from outside that block, it can 
declare a lexical variable containing an anonymous sub reference: 

    package hello;

    my $static_var = 23;
    my $static_func = sub { print $secret_version };
    &$secret_sub();  

Only the functions defined in this scope can access the variable as shown above. Also 
as long as the reference is never returned by any function within the module, no 
outside module can see the subroutine, because its name is not in any package's symbol 
table. One can't access the variable defined above by $hello::static_var in any other 
file . Also , this variable is not like a static variable in a function (like C) . It 
is like an "auto" variable in C.




---------------------------------
Get a bigger mailbox -- choose a size that fits your needs.

http://uk.docs.yahoo.com/mail_storage.html

Reply via email to