Difference between revisions of "Perl"
Jump to navigation
Jump to search
(→Syntax) |
|||
Line 15: | Line 15: | ||
==Syntax== | ==Syntax== | ||
+ | * pass command line arguments using @ARGV, access using $ARGV[n], count with $#ARGV | ||
* indicate end of program using the "__END__" token | * indicate end of program using the "__END__" token | ||
* specify certain version of perl by statement "use 5.005_54;" or similar | * specify certain version of perl by statement "use 5.005_54;" or similar | ||
+ | |||
+ | ===HTML::Tree module=== | ||
+ | * my $tree = HTML::TreeBuilder->new_from_file($file_path_string); | ||
+ | * $tree->delete(); | ||
+ | * $h->descendents() vs $h->lineage() | ||
+ | * $h->find( 'tag', ... ) = returns a list of elements at or under $h that have any of the specified tag names. | ||
+ | * $h->look_down( ...criteria... ) = THE BIG ONE | ||
+ | <pre>my @wide_pix_images = $h->look_down( "_tag", "img", "alt", "pix!", sub { $_[0]->attr(’width’) > 350 });</pre> |
Revision as of 22:22, 18 November 2009
Using Modules
- perldoc perllocal = shows what modules are installed on a given system
- get cpan if necessary and install (may also need Test::Simple and Digest::SHA to aid in downloading and checking of modules.
- sudo cpan -i Foo::Bar (get name of Foo::Bar from cpan.org)
- perldoc Foo::Bar = see user contributed perl documentation (man pages) of the module you just downloaded
Executables
- cpan
- perldoc = Look up Perl documentation in Pod format.
- -f perlfunc = look up specific builtin functions, ex: perldoc -f sprintf
Running Perl "perlrun"
- perl -V = Summary of perl5 configuration.
- perl -d and -D = debug options
Syntax
- pass command line arguments using @ARGV, access using $ARGV[n], count with $#ARGV
- indicate end of program using the "__END__" token
- specify certain version of perl by statement "use 5.005_54;" or similar
HTML::Tree module
- my $tree = HTML::TreeBuilder->new_from_file($file_path_string);
- $tree->delete();
- $h->descendents() vs $h->lineage()
- $h->find( 'tag', ... ) = returns a list of elements at or under $h that have any of the specified tag names.
- $h->look_down( ...criteria... ) = THE BIG ONE
my @wide_pix_images = $h->look_down( "_tag", "img", "alt", "pix!", sub { $_[0]->attr(’width’) > 350 });