My task (from a perl tutorial is to alter a program that prints line numbers on a file so that ->
"line numbers are printed as 001, 002, ..., 009, 010, 011, 012, etc. To do this you should only need to change one line by inserting an extra four characters. Perl's clever like that."
I print the line numbers easily enough:
$file = 'sta.txt';
open (TEXT, $file);
my $linenum;
while ($line = <TEXT>){
$linenum++;
print "$linenum "."$line";
}
The four characters to add to this script to format the line numbers mystifies me. Any suggestions?
"line numbers are printed as 001, 002, ..., 009, 010, 011, 012, etc. To do this you should only need to change one line by inserting an extra four characters. Perl's clever like that."
I print the line numbers easily enough:
$file = 'sta.txt';
open (TEXT, $file);
my $linenum;
while ($line = <TEXT>){
$linenum++;
print "$linenum "."$line";
}
The four characters to add to this script to format the line numbers mystifies me. Any suggestions?