LWP - LWP and Perl Copyright 1999-2005 Ellis Horowitz...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Copyright 1999-2005 Ellis Horowitz LWP and Perl
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Copyright 1999-2005 Ellis Horowitz Introduction • LWP stands for Library for World Wide Web in Perl – It is a set of Perl modules and object- orientede classes for getting data from the Web and extracting information from HTML • It is assumed that the web is accessed by people – but many times we want to access the information on a web page with a program
Background image of page 2
Copyright 1999-2005 Ellis Horowitz Is LWP Installed To test whether LWP is installed, try the command: pollux.usc.edu(1):perl -MLWP -le "print(LWP->VERSION)" 5.65 the response is the version number of the installed library
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Copyright 1999-2005 Ellis Horowitz LWP, An Example • Here is a program that counts the occurrences of the string "Perl" on the CPAN website. #!/usr/usc/bin/perl -w use strict; use LWP::Simple; my $catalog = get("http://www.cpan.org"); my $count = 0; $count++ while $catalog =~ m{Perl}gi; print "$count\n"; • the get() function returns the document at a given URL or undef if an error occurred.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/24/2011 for the course CSCI 571 at USC.

Page1 / 8

LWP - LWP and Perl Copyright 1999-2005 Ellis Horowitz...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online