Archive for the ‘Perl’ Category

Command line arguments with Perl

Posted: 27th December 2013 by Tim in Perl
Tags: , , , , ,

Command line arguments in perl are stored in the $ARGV array, and the number of arguments can be deduced from the size of that array: $#ARGV + 1. One way to access this data is to access the data by index: $ARGV[0] for the first argument for example. Unlike C, the program name is not […]

Perl regular expressions are slightly different from grep (or egrep) regular expressions. grep is sufficient most of the time, but sometimes you may need the extra flexibility of Perl regular expressions, or may just want to test out a regular expression that you will use later in Perl code. This can be done on the […]

Min and max functions in Perl

Posted: 1st February 2012 by Tim in Perl
Tags: , , , , ,

Min and max functions are available in perl, but you need to load them first. To do this, add use List::Util qw[min max]; to the top of the script. These functions take a list of numbers and return the min/max of that list. The list can have 1 number or 100 – it doesn’t matter: […]