The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::Dilbert - Dilbert of the day comic strip archive and retieval module

SYNOPSYS

 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();
         }
 }

DESCRIPTION

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.

METHODS

WWW::Dilbert Object Methods

Strip retrieval object.

new()

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'
get_todays_strip_from_website()

Returns a strip object containing todays Dilbert of the Day cartoon strip.

get_strip_from_website($strip_id)

Returns a strip object containing a specific Dilbert cartoon strip as downloaded from the Dilbert website.

get_strip_from_filename($filename)

Returns a strip object containing a specific Dilbert cartoon strip from a Dilbert comic stip file on disk.

get_strip_from_database($strip_id)
get_todays_strip_url()
get_random_strip_from_database()

WWW::Dilbert::Strip Object Methods

Strip object returned by WWW::Dilbert get methods.

insert_into_database()

Inserts the strip in to a database via the DBI database defined by the parent WWW::Dilbert object.

width()

Returns the width of the comic strip image.

height()

Returns the height of the comic strip image.

file_ext

Returns the file extension for the comic strip image format.

file_media_type

Returns the MIME type for the comic strip image format.

bytes()

Returns the total number of bytes of the comic strip image.

strip_blob()

Returns the binary image data of the comic strip image.

strip_id()

Returns the comic strip id.

SQL SCHEMA

 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)
 );
 

TODO

Remove the database functionality since it's pretty pointless.

Add retrieval of strips from the last 30 day online archive.

VERSION

$Id: Dilbert.pm,v 1.9 2005/12/08 15:48:09 nicolaw Exp $

AUTHOR

Nicola Worthington <nicolaw@cpan.org>

http://perlgirl.org.uk

ACKNOWLEDGEMENTS

Thanks go to David Dick <david_dick@iprimus.com.au> for the write_file() patch which he submitted on 22nd September 2004.

COPYRIGHT

(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