heh well the name sums it up, I originally made it to search through some chat logs to see how sentances I uses "heh" in a chat log I had... heh.
#!/usr/bin/perl -w #This Program will check to see on how many lines a word #or word fragment occurs print "Welcome to Uselessmaster 4000\n"; $op="S"; #Sets a Value to op so that there is no message about +it being uninitialized until ($op =~/Q/i) { print "Would you like to (S)earch a file or (Q)uit?\n"; $op=<STDIN>; if ($op =~/Q/i) { print "Just hit enter to shuffle though all prompts\n"; } print "enter the word you would like to check for\n"; chomp ($word=<STDIN>); print "enter the full pathname of the file you would like to search\n" +; $file=<STDIN>; open FILE, "<$file" or die "Sorry no luck opening file"; $totline=0; $occ=0; for $line (<FILE>) { $totline=$totline+1; if ($line =~/$word/i) {$occ=$occ+1;}; }; print "Of ",$totline," lines the word ",$word," occured on ",$occ," li +nes\n"; };
Ok after reading some of the suggestions here I decided to update the uselessmaster I would have prefered to post this in Seekers of Perl Wisdom but I decided instead that it would problably be a better idea just to edit my original post to include the second draft rather then clutter things up with a additional post, so heres the second version of the useless master.
#!/usr/bin/perl -w use strict; #This Program will check to see on how many lines a word or word fragm +ent occurs print "Welcome to Uselessmaster 4000\n"; my($totline,$op,$word,$file,$occ,$line); $op="S"; #Sets a Value to op so that there is no message about +it being uninitialized until ($op =~/Q/i) { print "enter the word you would like to check for\n"; chomp ($word=<STDIN>); print "enter the full pathname of the file you would like to search\n" +; $file=<STDIN>; open FILE, "<$file" or die "Sorry no luck opening file $!"; $totline=0; $occ=0; for $line (<FILE>) { $totline++; if ($line =~/$word/i) {$occ++;}; }; print "Of ",$totline," lines the word ",$word," occured on ",$occ," li +nes\n"; print "which is is ",$occ/$totline*100,"% of the lines\n\n"; print "Would you like to (S)earch another file or (Q)uit?\n"; $op=<STDIN>; };
Thank you all for the suggestions and I hope that the second version is a improvement over the first.

In reply to The Useless Master 4000 by Cobo

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.