This tutorial is a variation of the last one. As before, we read in lines of a data file and print them out with line numbers. The difference is that in this version, we specify the filename in the commandline parameters instead of redirecting standard input. (Feel free to compare the output of this script […]

Reading all the lines of a data file is a very basic operation. Perl lets you do this in a number of ways. The method of feeding the data file to the Perl program can either be a redirect from the command line, or through a specified filename:

> perl readfile.pl < inputfile.txt
> perl readfile.pl inputfile.txt

This […]