programming-examples/perl/File/Print out file line number.pl

14 lines
175 B
Perl
Raw Normal View History

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