Reading commandline parameter

Commandline parameters are values passed to the program from commandline when calling the program. For example:

$ perl sum.pl 4 5

sum.pl has two commandline arguments, 4 and 5.

All commandline parameters in Perl get inserted into the @ARGV array in the order they are typed. To access a values in the @ARGV array (for this example), we use $ARGV[0] and $ARGV[1].

#!/usr/bin/perl
print $ARGV[0] + $ARGV[1];

This program returns the sum of the two arguments passed in the commandline.