Pokémon Programming

This is a behind-the-scenes explanation of what's going on behind the Pokémon script. Below I'm exposing the Perl code of the four files involved. I'll add more documentation as I get comments.

Pokedex.pm
This is the main module that parses Pokemon data and pushes it into an internal cache. It exports three functions: get(), search(), and all(). The first returns a single Pokemon object, the other two return an array of Pokemon objects.
Pokemon.pm
This is an object-oriented module, which exports two static functions: displayas and sortby. Pokemon objects will be converted to strings. By default, they are printed as an HTML image tag and the name. This makes for a colorful display on CGI.
getimage.cgi
This is a trivial REST-style web service that returns a binary PNG image when passed an Pokemon number parameter "n". It can use methods from Pokedex.pm to extract the image if needed from an SWF file on the pokemon.com site.
testcode.cgi
This is the code processor. In addition to the exported functions of Pokedex.pm and Pokemon.pm, it exposes two utility functions: show and count. Show simply prints in HTML format, while count is just a synonym for scalar.

And again, here's the executable for testcode.cgi

Milo's Pokémon Program Tester