Say you've been given a list of keywords, and you want to find every news item in the database that matches at least one of those keywords. This problem might occur if someone has selected (or typed in) a series of words and wants to do an "OR" search, that is: find all items that match word-one, or word-two, or word-three, etc.
Find Match In A Set
A CPAN of My Own
If you're sharing a server, the first time you use CPAN you may find that it's already configured for the root account, in which case you'll get a load of errors about incorrect permissions to install anything. You can either try and get the root password, or (more likely) set up your own CPAN install. It's straightforward, if just a bit tedius.
mkdir -p ~/.cpan/CPAN cp /usr/lib/perl5/5.8.5/CPAN/Config.pm ~/.cpan/CPAN/MyConfig.pm perl -p -i -e 's!/root/!/home/michael/!g' ~/.cpan/CPAN/MyConfig.pm perl -MCPAN -eshell cpan> o conf makepl_arg "LIB=/home/michael/perl INSTALLMAN1DIR=/home/michael/perl/man1 INSTALLMAN3DIR=/home/michael/perl/man3" cpan> o conf commit cpan> install Some::Thing
Remote Differences
Want to see if the copy of that CGI script on your hard-drive is up-to-date with the one on the web server? Or maybe you suspect they're different in some small way, but can't tell by looking. Try something like this on the command-line...
ssh user@onperl.org 'cat www/cgi-bin/script.pl' | diff - script.pl
Matching Markup
I recently needed a way to translate simple markup into (uhm, another markup) HTML. The simple markup could be anything, but had to provide a way to format text entries. I figured POD was good enough.
Module Finder
If you're working on a system that has multiple versions of perl installed with perhaps multiple users and a few different library locations, you might be confused about where to look when you get a problem related to a module. Where is the code for that module actually located? Got more than one of those modules installed in different places, which one is being used? Which version?
Walking Recursively
Here's a quick recipe to scan a directory recursively (aka "walking") for all files that meet a given criteria--in this case I'm searching for perl scripts. In fact, because this is Perl, I'll give you three ways to do it!
