in reply to Re: Statistics from a txtfile
in thread Statistics from a txtfile
This is as far as I have got. Could you please elaborate on my coding further?#!/usr/bin/perl print("Please enter filename: "); $filename = <STDIN>; chomp ($filename); if ($filename=~m/^[_a-zA-Z][^.]{1,7}\.txt$/) open (READFILE, $filename)|| die "Failed to open $filename: $!"; my $filecontents; { local undef $/; $filecontents = <READFILE>; } while (<READFILE>) my @characters = ($filecontents =~m/\b/g); my @words = ($filecontents =~m/\b\s/g); my $wordcount = scalar @words; my @paragraph =($ my @sentences = ($filecontents=~m/\.$/); $CharCount{ $characters }++; $wordcount{ $wordcount)++; etc close <READFILE>; open(OUT, ">data1.txt") || die "data1.txt not open: $!"; output data here close(OUT);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Statistics from a txtfile
by hangon (Deacon) on Dec 31, 2007 at 19:44 UTC | |
by blazar (Canon) on Jan 02, 2008 at 21:17 UTC | |
by hangon (Deacon) on Jan 03, 2008 at 03:36 UTC |