Category Archives: Perl

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

References 2, Scratching at Complex Data Structures

Back again for another bite of the Alpaca? In order to take our references to the next level we need to start making arrays of arrays and arrays of hashes and other such complex arrangements. I’ll be starting of with … Continue reading

Posted in Perl | Tagged , , | Leave a comment

Perl References – In the beginning

I spend a few minutes here and there reading the ‘Alpaca’ book (Intermediate Perl) and feel its time to get a grip of references. It seems that a reference is only like a pointer in C so given that Perl … Continue reading

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

Sorting a list of email addresses with Perl (virtusertable)

I’ve always had a mental block when sorting with Perl, but I was asked to write a quick script to sort out the /etc/mail/virtusertable file for our sendmail setup. The format of the table is as follows: <email address> (whitespace) … Continue reading

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