NAME WWW::OhNoRobotCom::Search - search comic transcriptions on http://ohnorobot.com SYNOPSIS use strict; use warnings; use WWW::OhNoRobotCom::Search; my $site = WWW::OhNoRobotCom::Search->new; # search XKCD comics my $results_ref = $site->search( 'foo', comic_id => 56 ) or die $site->error; print "Results:\n", map { "$results_ref->{$_} ( $_ )\n" } keys %$results_ref; DESCRIPTION The module provides interface to perform searches on comic transcriptions website. CONSTRUCTOR new my $site = WWW::OhNoRobotCom::Search->new; my $site = WWW::OhNoRobotCom::Search->new( timeout => 10, ); my $site = WWW::OhNoRobotCom::Search->new( ua => LWP::UserAgent->new( timeout => 10, agent => 'robotos', ), ); Constructs and returns a brand new yummy juicy WWW::OhNoRobotCom::Search object. Takes two arguments, both are *optional*. Possible arguments are as follows: timeout ->new( timeout => 10 ); Optional. Specifies the "timeout" argument of LWP::UserAgent's constructor, which is used for searching. Defaults to: 30 seconds. ua ->new( ua => LWP::UserAgent->new( agent => 'Foos!' ) ); Optional. If the "timeout" argument is not enough for your needs of mutilating the LWP::UserAgent object used for searching, feel free to specify the "ua" argument which takes an LWP::UserAgent object as a value. Note: the "timeout" argument to the constructor will not do anything if you specify the "ua" argument as well. Defaults to: plain boring default LWP::UserAgent object with "timeout" argument set to whatever "WWW::OhNoRobotCom::Search"'s "timeout" argument is set to as well as "agent" argument is set to mimic Firefox. METHODS search my $results_ref = $site->search('foo') or die $site->error; my $xkcd_results_ref = $site->search( 'foo', comic_id => 56, include => [ qw(all_text meta) ], max_results => 20, ) or die $site->error; my $uri = $site->search( 'foo', lucky => 1 ) or die "No lucky :(" . $site->error; Instructs the object to perform a search. If an error occured returns either "undef" or an empty list depending on the context and the description of the error will be available via "error()" method. On success, returns a (possibly empty) hashref where keys are URI's poiting to comics and values are titles presented in search results unless the "lucky" (see below) argument is set, in which case it will return a URI object pointing to the *Let the robot decide* URI or will "error out" with the "Nothing was found" in the "error()" message. Takes one mandatory argument and several optional arguments. Note: the "search()" can make several requests, (see "max_results"'s argument) but it will tell you about only the *first* network error, any network errors occuring later during the search will not be reported, will be silently skipped and the internal "results found" counter will be increased by 10 to prevent any infinite loops. The first argument (mandatory) is the term you want to search. The other, optional, arguments are given in a key/value fashion and are as follows: comic_id $site->search( 'term', comic_id => 56 ); The "comic_id" argument takes a scalar as a value which should be a comic ID number or an empty string which indicates that search should be done on all comics. To obtain the comic ID number go to , "View Source" and search for the name of the comic, when you'll find an