Perl 201
Riding the Camel
Douglas E. Miles
- Introduction
- Perl 201 is an introduction.
- Documentation
- man perl (or HTML equivalent)
- Programming Perl (O'Reilly)
- Object Oriented Perl (Manning)
- Perl Cookbook
- Mastering Regular Expressions (O'Reilly)
- CPAN -
http://search.cpan.org/
- Google
- Strict and Warnings
- Strict
- use strict; # apply all possible restrictions
- use strict 'vars'; # restrict unsafe use of variables for rest of block
- use strict 'refs'; # restrict unsafe use of references for rest of block
- use strict 'subs'; # restrict unsafe use of barewords for rest of block
- perl -w;
- Scope
- Programming Perl 2nd ed. Ch. 2 Section 6.8
A local variable is dynamically scoped, whereas a my variable is lexically
scoped. The difference is that any dynamic variables are also visible to
functions called from within the block in which those variables are
declared. Lexical variables are not. They are totally hidden from the
outside world, including any called subroutines (even if it's the same
subroutine called from itself or elsewhere - every instance of the
subroutine gets its own copy of the variables). In either event, the
variable (or local value) disappears when the program exits the lexical
scope in which the my or local finds itself. By and large, you should
prefer to use my over local because it's faster and safer. But you have
to use local if you want to temporarily change the value of an existing
global variable, such as any of the special variables listed at the end of
this chapter. Only alphanumeric identifiers may be lexically scoped.
- my
- local
- Regular Expressions
- Line Noise
- Examples
- References
- Symbolic
- Hard
- Data Structures
- man perldsc
- List of Lists (Array of Arrays)
- List of Hashes (Array of Hashes)
- Hash of Lists (Hash of Arrays)
- Hash of Hashes (Hash of Hashes)
- Packages
- Typeglobs - Everything named 'foo' or a symbol table entry. i.e.
$foo, @foo, %foo, &foo, and foo.
- Symbol Tables - Hash whose name is the same
as the package with '::' appended.
- Objects
- A class is a package.
- An object is a referent (something being refered to) that knows which class (package) it belongs to.
- A method is a subroutine that expects an object reference (or a package name, for class methods) as its first argument.
- Example
- Modules
- Same name as package and ends in .pm, and '::' changes to '/'.
- h2xs
-
Comprehensive Perl Archive Network - http://www.perl.com/CPAN/
- perl -MCPAN -e shell
- References
- Learning Perl (The Llama)
- Programming Perl (The Camel)
- The Perl man pages
- Object Oriented Perl
- perltoot (Tom's Object-Oriented Tutorial)