Hello oh wise ones, I am totally stuck with a probelm that I have and need desperate help.

I need to open a txt file and output statistics to another file. The program must be able to:

ask for a filename
check file to see if its ms-dos file format
filename should be no longer than 8 characters and should begin with an _underscore or letter and should end with .txt not case sensitive
if not then it should add .txt
program should check whether file exists and not empty
should read the file by character and get the following statistics:
character count including whitespace the punctuation. number of words. paragraphs. lines and sentences. output details to a separate .txt file.
I don’t have much so far as I have a headache from the what I’ve done so far. Yes, I’m not very good with perl.

$pattern=”.txt”;
print (“enter filename: “);
$filename=<STDIN>;
if ($filename=~m/^a-zA-Z{1}\_{1}$pattern$/i)

Also I understand that i'll open the file with the following:

open (READFILE, $filename)|| die "error message";

AND THATS IT!!!!

I’m not looking for someone to to do the whole thing for me but more nudge me in the right direction with the structure. Please please please


In reply to Statistics from a txtfile by mbdc566021

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.