#!/usr/bin/env perl # Blog-Like-A-Pirate for Blosxom, by Rob Hague -*-perl-*- # See http://www.rho.org.uk, http://www.blosxom.com and # http://talklikeapirate.com/. Aar! package bloglikeapirate; # --- Configurable variables ----- # The English-to-Pirate Dictionary @substitutions = (['\bis\b','be'], ['\b(([Ii]t)|([Tt]here))\'s\b','$1 be'], ['\. ','. ','. ','. Avast, '], ['
','
','
', '
Shiver me timbers. ','
Yar. ', '
Avast, me hearties. '], ['
','','', ' Yo ho ho and a bottle of rum.', ' Aarr!'], ['\bYes\b','Aye'], ['\byes\b','aye'], ['\bbeer\b','grog'], ['\bHello\b','Ahoy'],['\bhello\b','ahoy'], ['\bfriend'],['shipmate'], ['\bmy\b','me']); # -------------------------------- sub start { 1; } sub story { my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_; if ($meta::scurvey) { return 1; }; srand $$title_ref; filter_text($title_ref); filter_text($body_ref); return 1; } sub filter_text { my ($text_ref) = shift; foreach $s (@substitutions) { $$text_ref =~ s/$s->[0]/'"' . $s->[1+int(rand ($#{$s}))] . '"'/eeg; } } # Act like a normal Unix command if invoked on the command line if ($0 =~ /bloglikeapirate/) { srand "Shiver Me Timbers"; # Ensure consistent output while (<>) { filter_text(\$_); print; } } 1; __END__ =head1 NAME Blosxom Plug-in: Blog-Like-A-Pirate =head1 SYNOPSIS Purpose: Turns your posts into pirate-speak. Aar! Description Just drop it in your plugin directory. Also works from the command line; provide filenames as arguments, or data on standard input. Configuration Customise the english-to-pirate dictionary as you see fit; each entry is a list, the first item of which is a regular expression to match, the others being substitution terms. One of these is chosen at pseudorandom for each match. Additional Bits Required Category /display/stupid Date 2003-09-18 Todo list =head1 VERSION 2.0rc5 Version number coincides with the version of Blosxom with which the current version was first bundled. =head1 AUTHOR Rob Hague