|
Good day to you folks,
I am currently learning to program and I have been given the task of solving a file list line counter. The current program I have written only reads 1 of the files I input and not all...
#!/usr/bin/perl
use strict;
use warnings;
my $longest = -1 ;
my $shortest = -1;
my $line_total = 0;
while (my $line = <>) {
chomp ($line);
$line_total += 1;
#print(length($line),"\n");
if (length ($line) > $longest){
$longest = length ($line);
}
if ($shortest < 0 || length ($line) < $shortest){
$shortest = length ($line);
}
}
print("\n$ARGV $line_total lines, longest=$longest shortest=$shortest\n");
I need to make the output display something like this:
freddy 45 lines, longest=34 shortest=3
freddy_2 57 lines, longest=67 shortest=13
freddy_3 308 lines, longest=308 shortest=61
I need to know exactly where I am going wrong and why?
Many thanks,
Dave
|
|
|
You must design your own code.
Once there is some technical issue about how excactly to do something very specific... then ask here.
|
|
|
|
|
|
|
// |