Tag Archives: Perl

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

Timing the Execution Time of a Script

If you want to test the time it takes to run a script, you can use the UNIX ‘time’ command. the manual page states: The time utility executes and times the specified utility. After the utility finishes, time writes to … Continue reading

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

Final Virtusertable Perl Sort

As the final stage of the sorting posts, I’ve converted the original virtusertable sort to the ‘Schwartzian Transform’ with multiple sorts. Notice i create the ‘sub arrays’ with 3 items: $_[0] = “user@domain <whitespace> target” $_[1] = “domain” $_[2] = … Continue reading

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

Perl Sorting with a bit more efficiency

I’ve modified the script from the last post to illustrate how many times the get_value function is called. #! /usr/bin/perl -w use strict; my %letter_vals; my $counter = 1; my $function_calls = 0; # function to calculate the ‘value’ of … Continue reading

Posted in Perl | Tagged , , | Leave a comment

More Perl sorting

After my last post about perl sorting, a friend of mine, who is an ardent hater of Perl (amongst a long list of other things), pointed out that his shell script was not only shorter, but also faster at sorting … Continue reading

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