Here's what I have so far:
#!/perl/bin/perl -w # text analyzer use strict; use CGI qw/:standard/; print header(); print start_html("This will count your words"); # check for param, if params present, then form is submitted if(param()) { my $fname = param ('fname'); if(!$fname){ dienice("You did not enter your name, please click the back bu +tton\n"); } # code for assigning variables for each param # get all other data and check if present, otherwise dienice my $email = param('email'); if(!$email){ dienice("You did not enter your email, please click the back b +utton\n"); } my $text2count = param('text2count'); # get a text array from text my @textarray = get_text_array($text); # make a hash out of this array @textarray my %texthash = get_counting_hash(@textarray); # after get all of the values needed, print out the content for th +e result: print <<EOHTML1; # I know I need to do a foreach loop here with a table tag before +the loop and and ending table tag after the loop EOHTML1 } else { #print the HTML form out here so we can get the name,email and the + text print <<EOHTML; # THIS IS WHERE THE FORM WILL GO - LEFT THIS OUT TO CHOP CODE +- This I have completed EOHTML } print end_html(); # end of the page right here # subroutine to die - provided by our teacher sub dienice { my ($s) = @_; print $s, "\n"; exit(1); } # make a text array out of the plain text sub get_text_array { return split(/ /, $_[0]); } # building a hash counting words from an array of words # the keys are the words # the values are the number of occurrences of that word in the array sub get_counting_hash { my @wordArray = @_; my %wordHash = (); # I think I need some code here? return %wordHash; }
I'm hazy on the foreach loop to make the table and also on the subroutine get_counting_hash...

In reply to The Code for counting unique words (help?) by iridius
in thread Just starting out with Perl by iridius

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.