programming-examples/perl/File/Print out file line number.pl
2019-11-15 12:59:38 +01:00

14 lines
175 B
Perl

#!/usr/bin/perl -w
use strict;
open(FILE, '<', 'yourFile.txt') or die $!;
my $lineno = 1;
while (<FILE>) {
print $lineno++;
print ": $_";
}
close FH;