Krammer
November 18th, 2003, 08:44 PM
How do I find the longest word in the text file and print it in PERL...and compute the average word length and the average sentece length of a text file.
This is what I have so far....
print "What File would you like to open?";
$file= <STDIN>;
open INFILE, $file or die "File not Found \n";
@text = <INFILE>; #creates an array name @text, loads the contents of the file
print"\n";
print"\n"; print "array output begins here"; print "\n";
print @text;
print"\n"; print "\n"; print "** One Line at a Time \n";
$file = length;
$max1 = $file if $file > $max1;
print "$max1\n" if eof;
for($idx=0; $idx<=@text; $idx++)
{
{print substr(@text[$idx],0,7); print "\n";}
++$file;
}
This is what I have so far....
print "What File would you like to open?";
$file= <STDIN>;
open INFILE, $file or die "File not Found \n";
@text = <INFILE>; #creates an array name @text, loads the contents of the file
print"\n";
print"\n"; print "array output begins here"; print "\n";
print @text;
print"\n"; print "\n"; print "** One Line at a Time \n";
$file = length;
$max1 = $file if $file > $max1;
print "$max1\n" if eof;
for($idx=0; $idx<=@text; $idx++)
{
{print substr(@text[$idx],0,7); print "\n";}
++$file;
}