| next | prev | What Works | Slide #97 |
Hides the underlying complexity.
Example: LWP vs LWP::Simple
Here's how to get a web page in LWP
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->agent("$0/0.1 " . $ua->agent);
# $ua->agent("Mozilla/8.0") # pretend we are very capable browser
$req = HTTP::Request->new(GET => 'http://www.linpro.no/lwp');
$req->header('Accept' => 'text/html');
# send request
$res = $ua->request($req);
# check the outcome
if ($res->is_success) {
print $res->content;
}
Here's the similar effect with LWP::Simple (a wrapper around LWP)
use LWP::Simple;
getprint('http://www.linpro.no/lwp');
Sometimes, you just don't need all that power.
| next | prev | ToC | Copyright © 2002-2003 Norman Nunley & Michael G Schwern |