#!/usr/bin/perl use strict; my $i=0; open(FD,"abb.txt")||die "ERROR: can not read file abb.txt\n"; while(){ # increment the line counter. You probably # know the ++ from C: $i++; print "Line $i is $_"; } close FD;