At first reading, the reason is because you're using one global hash %wordHash whereas what you actually want to do is use a fresh hash for each line you read in the input. At least, I think so. If I'm right then the solution is to put the line

my %wordHash;
right inside your outer while loop. I also doubt that your inner loop does what you really want it to, but I'm not sure.

Which brings me to my main point. I'm sorry to be blunt, but this needs to be said. When you are asking for help on an Internet forum, a terrible way to go about it is to say "you can kinda guess what im trying to do." Instead, say what you're trying to do clearly and concisely, then show the code. When you do that, your friendly readers may notice something about your code that's not going to work, based on your stated purpose. But without that stated purpose, we have no idea whether the code is "working" or not. So please help us out.

Update: One other thing. The way you're adding elements to the array, using $i, will work but I strongly encourage you to use push instead because it's clearer and less likely to have errors.


In reply to Re: punctuation search... using ascii by Errto
in thread punctuation search... using ascii by Yoda_Oz

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.