Monthly Archives: October 2011

Perl match in scalar and list context (regex)

Sometimes it takes a throw-away comment in a book for a whole stack of jumbled info to just slot into place. The ‘Sixth Sense’ is on the telly and my wife is asking why she ‘didn’t notice it’ (the fact … Continue reading

Posted in Perl | Tagged , , , | Leave a comment

Perl array remove duplicate values – Update

Great news! I used the function from yesterdays post in a production script today. the script searches a log file on a 60 min basis and grab usernames and passwords, removes the dupes and enters the usernames and passwords to … Continue reading

Posted in Perl | Tagged , | Leave a comment

Removing duplicates from a Perl array – really this time

My last post got a bit sidetracked and i didn’t do a simple removal of dupes from an array. As I said last time, hashes cannot have duplicate keys, so the easiest way to do this is to simply create … Continue reading

Posted in Perl | Tagged , , , , | Leave a comment

Perl and ‘uniq’ – de-duping arrays and other tricks

There comes a time when everybody needs to de-dupe an array, or just simulate the UNIX uniq command. Here at $dayjob, for example, we do quite a lot of UNIX shell commands to look up the number of times has … Continue reading

Posted in Perl | Tagged , , , , | Leave a comment

Perl DBI MySQL failover databases

Further to the last post on Eval, here is how we can try server A, then if it fails, use server B instead. The hub of the issue is ‘or die’ , ‘or warn’ and ‘or’. Here is my test … Continue reading

Posted in MySQL, Perl | Tagged , , | Leave a comment

Trapping Errors with Eval

The end game of this task is to modify some MySQL based logging so it will try to connect to a central logging server, and if that fails, log to the local server, the update the central server when it … Continue reading

Posted in Perl | Tagged , , | Leave a comment

Upgrading Perl 5.10 to 5.12 on FreeBSD

So a customer asked to use the latest version of Perl on one of our web servers. Its Running FreeBSD 8.0 with Apache2.2 and Perl 5.10. The FreeBSD ports collection does not upgrade 5.10 to 5.12 with a normal upgrade … Continue reading

Posted in FreeBSD Administration, Perl | Tagged , , | Leave a comment

Notes on the Vacation program – multiple aliases

Is it possible to have multiple aliases with vacation? Yes! Imagine you have a sendmail setup with a virtusetable that looks like this: fred@domain_name.com fred fredrick@domain_name.com fred fred.bloggs@domain_name.com fred And you want to use vacation for an out of office … Continue reading

Posted in FreeBSD Administration | Tagged , , , | Leave a comment