Difference between revisions of "Perl"
Jump to navigation
Jump to search
(→Syntax) |
|||
Line 1: | Line 1: | ||
==Using Modules== | ==Using Modules== | ||
− | * perldoc perllocal = shows what modules | + | * perldoc perllocal = shows what modules have been installed via cpan or manually on the current system |
* get cpan if necessary and install (may also need Test::Simple and Digest::SHA to aid in downloading and checking of modules. | * 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) | * sudo cpan -i Foo::Bar (get name of Foo::Bar from cpan.org) |
Revision as of 18:51, 23 November 2009
Using Modules
- perldoc perllocal = shows what modules have been installed via cpan or manually on the current 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 });