WWW::Dilbert - Dilbert of the day comic strip archive and retieval module
use WWW::Dilbert; my $dilbert = new WWW::Dilbert; my $strip = $dilbert->get_todays_strip_from_website(); use WWW::Dilbert; my $dilbert = new WWW::Dilbert( dbi_dsn => 'DBI:mysql:nicolaw:localhost', dbi_user => 'username', dbi_pass => 'password' ); chdir '/home/albert/my_dilbert_archive_directory'; if (opendir(DH,'.')) { for (grep(/dilbert[0-9]{10,14}\.gif$/, readdir(DH))) { my $strip = $dilbert->get_strip_from_filename($_); $strip->insert_into_database(); } }
This module will download the latest Dilbert of the Day cartoon strip from the Dilbert website and return an object which can be either stored in a database or output to a browser, disk or whatever. It allows importing of Dilbert strips from disk or alternate URLs, and has a random strip interface to return strips from the database.
Strip retrieval object.
Create a new WWW::Dilbert strip retrieval object. Accepts the following key-value pairs:
dbi_dns => 'DBI:mysql:database:hostname', dbi_user => 'username', dbi_pass => 'password'
Returns a strip object containing todays Dilbert of the Day cartoon strip.
Returns a strip object containing a specific Dilbert cartoon strip as downloaded from the Dilbert website.
Returns a strip object containing a specific Dilbert cartoon strip from a Dilbert comic stip file on disk.
Strip object returned by WWW::Dilbert get methods.
Inserts the strip in to a database via the DBI database defined by the parent WWW::Dilbert object.
Returns the width of the comic strip image.
Returns the height of the comic strip image.
Returns the file extension for the comic strip image format.
Returns the MIME type for the comic strip image format.
Returns the total number of bytes of the comic strip image.
Returns the binary image data of the comic strip image.
Returns the comic strip id.
CREATE TABLE dilbert_character ( id int unsigned not null primary key auto_increment, name char(100) not null, regular_character bool default null, notes text, photo_blob blob ); CREATE TABLE dilbert_strip ( id bigint(14) unsigned not null primary key, strip_blob mediumblob not null, bytes int unsigned not null, width int(4) unsigned not null, height int(4) unsigned not null, colour bool default null, cells enum('3','6','-1') default "3" not null, text text ); CREATE TABLE dilbert_character2dilbert_strip ( dilbert_character_id int unsigned not null, dilbert_strip_id bigint(14) unsigned not null, primary key (dilbert_character_id, dilbert_strip_id) );
Remove the database functionality since it's pretty pointless.
Add retrieval of strips from the last 30 day online archive.
$Id: Dilbert.pm,v 1.9 2005/12/08 15:48:09 nicolaw Exp $
Nicola Worthington <nicolaw@cpan.org>
http://perlgirl.org.uk
Thanks go to David Dick <david_dick@iprimus.com.au> for the write_file() patch which he submitted on 22nd September 2004.
(c) Nicola Worthington 2004, 2005. This program is free software; you can redistribute it and/or modify it under the GNU GPL.
See the file COPYING in this distribution, or http://www.gnu.org/licenses/gpl.txt
To install WWW::Dilbert, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::Dilbert
CPAN shell
perl -MCPAN -e shell install WWW::Dilbert
For more information on module installation, please visit the detailed CPAN module installation guide.