Hi, I'm very new to programming and I am having problems writing a program. I realize that you do not like to answer questions regarding homework and I want to use this program in a project for a course in computational linguistics, but I have never programmed before the past month, I have attempted to write a program to solve my problem, and I have looked through numerous online tutorials and sources. I am not sure where else to turn. My code looks like this:

#!/usr/local/bin/perl -w # Program to count minimal pairs by gender # Author: Katy # Last modified: December 2006 %Goodwords = ("mhm" => 1, "right" => 1, "well" => 1, "yeah" => 1, "sure" => 1, "good" => 1, "ah" => 1, "okay" => 1, "yep" => 1, "hm" => 1, "definitely" => 1, "alright" => 1, "'m'm" => 1, "oh" => 1, "my" => 1, "god" => 1, "wow" => 1, "uhuh" => 1, "exactly" => 1, "yup" => 1, "mkay" => 1, "i see" => 1, "ooh" => 1, "cool" => 1, "uh" => 1, "fine" => 1, "true" => 1, "hm'm" => 1, "hmm" => 1, "yes" => 1, "absolutely" => 1, "great" => 1, "um" => 1, "so" => 1, "mm" => 1, "weird" => 1, "ye-" => 1, "i mean" => 1, "i know" => 1, "i think so" => 1, "huh" => 1, "yay" => 1, "maybe" => 1, "eh" => 1, "obviously" => 1, "correct" => 1, "awesome" => 1, "really" => 1, "interesting" => 1,); while(<>){ if(/<strong>(S[\w\-]+)<strong>:.*Gender:\s+(Male|Female)/i){ $speakerID = $1; $speaker{$1}=$2;} if($good){ $good = 1; $minresgen{$speaker{$speakerID}}++;} $_=~ /\[(S[\w\-]+):(.*?)\]/i; use diagnostics; $minres = $2; $speakerID = $1; $minres =~ s/<.*?>//g; $minres = lc($minres); $good = 1; while($minres =~ /(\w+)/g) { unless($Goodwords{$1}) { $good = 0; last; } } print "Male:"; print $minresgen {"Male"}; print "Female:"; print $minresgen {"Female"}; }
My data are transcriptions of conversations and a sample looks like this:
<strong>S1</strong>: Native-Speaker Status: Native speaker, American E +nglish; Academic Role: Senior Undergraduate; Gender: Male; Age: 17-23 +; Restriction: None<br> <strong>S2</strong>: Native-Speaker Status: Native speaker, American E +nglish; Academic Role: Researcher; Gender: Male; Age: 31-50; Restrict +ion: Cite<br> <strong>S3</strong>: Native-Speaker Status: Native speaker, American E +nglish; Academic Role: Junior Undergraduate; Gender: Female; Age: 17- +23; Restriction: None<br> <strong>S4</strong>: Native-Speaker Status: Native speaker, American E +nglish; Academic Role: Senior Undergraduate; Gender: Female; Age: 17- +23; Restriction: None<br> <strong>S5</strong>: Native-Speaker Status: Native speaker, American E +nglish; Academic Role: Junior Undergraduate; Gender: Female; Age: 17- +23; Restriction: None<br> <strong>SS</strong>: Native-Speaker Status: Native speaker, American E +nglish; Academic Role: Unknown; Gender: Male; Age: Unknown; Restricti +on: None<br> <p><b>S1: </b> it was presented to them by Chuck D and Public Enemy. +<font color="#ff6600"><b> [S2: </b> mhm <b> ] </b></font> and the re +st of th- Public Enemy and you know and and Chuck D's f- publicly get +s up and says you know they were with us from the beginning and, <fo +nt color="#ff6600"><b> [S2: </b> <font color="#3333ff"> mhm </font> +<b> ] </b></font> <font color="#3333ff"> all that </font> now wheth- +whether or not you know that he was reading a TelePrompTer, <font co +lor="#ff6600"><b> [S2: </b> mhm <b> ] </b></font> or or not i i thin +k is uh </p> <p><b>S2: </b> or if he was trying to make nice because of the fact t +hat Public Enemy hasn't sold records lately, <font color="#ff6600">< +b> [S1: </b> right <b> ] </b></font> and he doesn't wanna look like +some kinda old sourpuss </p>
I want to get an output that looks like: "Male:" number of times that male speakers use any of the words in the hash singularly or in combination with each other when they are within brackets. "Female:" number of times that female speakers use any of the words in the hash singularly or in combination with each other when they are within brackets. When I run the program, the only output are four warning messages that repeat for each line of text that it processes, for example, line 557:
Use of uninitialized value in hash element at C:\Documents and Settings\Owner\Desktop\minres10.pl.txt line 62, <> line 557 (#1) Use of uninitialized value in substitution (s///) at C:\Documents and Settings\Owner\Desktop\minres10.pl.txt line 67, <> line 557 (#1) Use of uninitialized value in print at C:\Documents and Settings\Owner\Desktop\minres10.pl.txt line 78, <> line 557 (#1) Use of uninitialized value in print at C:\Documents and Settings\Owner\Desktop\minres10.pl.txt line 80, <> line 557 (#1)
and then there is a block of "Male:Female:Male:Female:" at the bottom of the output. When I used "use strict;" the program did not run and it sent back messages:
Variable "$speakerID" is not imported at C:\Documents and Settings\Owner\Desktop\minres10.pl.txt line 67 (#1) (F) While "use strict" in effect, you referred to a global variable that you apparently thought was imported from another module, because something else of the same name (usually a subroutine) is exported by that module. It usually means you put the wrong funny character on the front of your variable. Variable "$good" is not imported at ... line 70 (#1) Variable "%Goodwords" is not imported at ... line 72 (#1) Variable "$good" is not imported at ... line 73 (#1) Variable "%minresgen" is not imported at ... line 79 (#1) Variable "%minresgen" is not imported at ... line 81 (#1) Global symbol "$minres" requires explicit package name at ...line 66 ..."$speakerID" ...line 67 ..."$minres" ... line 68 ... "$minres" ... line 69 ... "$minres" ... line 69 ... "$good" ... line 70 ... "$minres" ... line 71 ..."%Goodwords" ... line 72 ..."$good" ... line 73 ..."%minresgen" ... line 79 ..."%minresgen" ... line 81 (F) You've said "use strict vars," which indicates that all variables must either be lexically scoped (using "my"), declared beforehand using "our," or explicitly qualified to say which package the global variable is in (using "::").
I am using ActivePerl 5.8.8.819 Windows (x86) AS package. Any advice on how I should change my script to make the program give me my desired output would be greatly appreciated. Thanks, Katy

In reply to minimal response program code problem by Katy

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.