A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Perl OO

our @ISA = ('MyParent');

sub new {
        my $proto = shift;
        my $class = ref($proto) || $proto;
        my $self  = {};
        $self->{NAME}   = undef;
        $self->{AGE}    = undef;
        $self->{PEERS}  = [];
        bless ($self, $class);
        return $self;
}

Use Perl-like regular expression in vi

You have to escape some special characters and not others:

s/"\(.\+\)\$/"\1"} = "\1"/

Escape special pluses, capturing parentheses and literal $

use \1 for the captured strings.

is reserved

While attempting to read the filehandle that you think points to a file, you get this error:

Modification of a read-only value attempted

Maybe this means the script is reading from the inline __DATA__ section, and you're trying to write to it?

Make IMAP Gmail work on blackberry

If you enter your Google email address when prompted, there is no way to configure advanced settings to make IMAP accounts work. In fact, I called Orange and was told that their Blackberries do not support IMAP with Gmail, and it does not work.

But they are wrong. It does work - you need to enter an email address that is not one of the major commercial providers, but does host email accounts. I used a fake email alias @ a domain I know has a working mail record: siteaboutnothing.com

Then, as you follow the prompts, choose "Advanced settings" or similar, and you are able to set the server to imap.gmail.com and change the email address back to your gmail account.

I now have it set up so messages marked as read on my phone are sync'ed with my main gmail account and I don't have to manage two accounts at once.

Email output from the crontab

method 1 - for all commands

Add this as the first line of crontab:

MAILTO=address1@host.com,address2@host.co.uk

method 2 - for specific commands

Add this line anywhere near the top:

NOTIFY_LIST="address1@host.com,address2@host.co.uk"

Use this for the command:

00 09 * * * run_command | mail -s "command has run" $NOTIFY_LIST