programming-examples/perl/File/Numbering Lines in Multiple Files.pl

15 lines
259 B
Perl
Raw Normal View History

2019-11-15 12:59:38 +01:00
#!/usr/bin/perl
use warnings;
use strict;
my $lineno;
my $current = "";
while (<>) {
if ($current ne $ARGV) {
$current = $ARGV;
print "\n\t\tFile: $ARGV\n\n";
$lineno=1;
}
print $lineno++;
print ": $_";
}