codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  printing multiple files from the <>  DevDave at 07:39 on Monday, January 22, 2007
 

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



  Re: printing multiple files from the <>  mimir at 16:06 on Saturday, February 24, 2007
 

You must design your own code.

Once there is some technical issue about how excactly to do something very specific... then ask here.









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Date script issues
•  perl script help needed
•  onChange issue
•  perl remote execution
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007