Perl Tutorial : Perl data types
Perl Tutorial : Perl Operators
Perl Tutorial : Perl loops
Perl Tutorial : Perl Conditionals
Perl Tutorial : Perl Subroutines
Perl Tutorial : Perl regex
Perl Tutorial : Perl Files
Perl Tutorial : Perl & Databases
Perl Tutorial : Perl OOPs
Perl Tutorial : Perl signals
Perl Tutorial : Perl threads
Perl Tutorial : Perl Debugging

Introcution to Perl CGI

Introduction to modperl
Home >> perlsubroutines >>

When to use my local?

Variables declared with the my() construct are considered to be lexical local variables. These variables are not entered in the symbol table for the current package; therefore, they are totally hidden from all contexts other than the local block within which they are declared. Even subroutines called from the current block cannot access lexical local variables in that block.Lexical local variables must begin with an alphanumeric character (or an underscore).

Variables declared by means of the local() construct are considered to be dynamic local variables. The value is local to the current block and any calls from that block. You can localize special variables as dynamic local variables, but you cannot make them into lexical local variables. These two differences from lexical local variables show the two cases in Perl 5.0 in which it is still advisable to use local() rather than my():

  • Use local() if you want the value of the local variables to be visible to subroutines.
  • Use local() if you are localizing special variables.

    Perl functions

    scalars and strings

    lc
    ord

    regex (regular expressions)

    arrays

    shift
    split

    More..

    eval
  • Share |

    Perl Subroutines

    Perl examples

  • How to use Data::Dumper?
  • How to parse config file?
  • Include external module in perl..
  • Download perl

    download stable version of perl
    Perl 5.10.1
    Perl interview Questions
    sed tutorial
    awk tutorial

    Join us on Google Groups

    Subscribe to perl
    Email:
    Visit this group
    Perl Jobs


    privacy | sitemap | disclaim | contact us
    © 2009 perlhome.com