Category Archives: Perl

Getting all Second Level Domains from Wikipedia 0

Just hacked up this little script to do the needful:

Incorporate gravatars into your application 0

It’s super easy:

#/usr/bin/perl
use strict;
use Digest::MD5 qw( md5_hex );
 
my $email = shift || die("Please provide email address\n");
my $hash = md5_hex lc($email);
 
print "http://gravatar.com/avatar/${hash}.jpg\n";

I use them at work for showing tooltip displays upon email receipt etc. They’re fun and handy to add to any little application.

Quick launcher for ISO files and kids games 0

We only run linux at home, but my kids have a few game titles that I’ve stored (err, protected) on disk as ISO files. It’s a real PITA to write down the command line options for my wife to execute when they feel like playing a game, so I’ve thrown together a few quick [...]

Perl ACL library 0

Hacked together a little ACL package for creating dynamic ACLs based on a few simple ideas:

Sys-Admins like Perl style Regex
Must be versatile enough to handle many types of applications
Should be robust enough to handle auto-generated ACLs

I was sitting at $WORK, thinking of a way to restrict access to certain API calls from a shared script.  [...]

A better way to write OO Perl 0

Use the MooseX::Declare syntactic sugar.

Perl + VIM + Refactor 0

In my last post, I spoke about tools to prettify vim and perl. Today I’m trying to tackle the problem of fat fingers when refactoring Perl code in VIM.
I’m always on the lookout for refactoring tools for VIM and Perl. Today I found APP::EditorTools which allows you to rename variables etc.
The power of [...]

Writing Perl with VIM 1

At $WORK I programme mostly in Perl, using VIM as my primary editor.  In order to make my life a little easier when it comes to looking at the sometimes horribly ugly syntax of Perl, and to ensure that I maintain a consistent style, I use Perltidy and a little VIM hackery to get the [...]

Lock your files 0

Many people don’t do this, but whenever you’re working with files that can be touched by multiple processes, be sure to lock those files!

#!/usr/bin/perl -w
use strict;
use Fcntl qw(:DEFAULT :flock);
 
my $filename = ‘/tmp/test_lock_file’;
 
open FD, "<$filename" or die( "Cannot open $filename: $!\n" );
 
unless( flock( FD, LOCK_EX | LOCK_NB ) ){
[...]

SSL Cert verification script 0

I maintain all of the private keys and certs for work, and one of the things that makes my life a lot easier is when I receive a CRT back from GeoTrust, and I want to ensure that the CRT indeed came from the supplied CSR, which indeed was generated from my private KEY.
I use [...]

Check if your outbound relays are blacklisted 0

I’ve just written two simple little scripts to check if your outbound relays are on any known blacklists.
The first script “spf_lookup.pl” is used to extract CIDR ranges from a domains SPF record.  This output is used to drive the rbl lookups of our next script.
The second part is our “rbllookup_async.pl” script, which checks a series [...]