jbert and liverpole have given you some pointers to get you further along. This post is to show you how to save a lot of typing when setting up your %Goodwords hash. Since all you are storing for values in the hash is 1, you can set all of the keys up first in an array and then use a map or a foreach loop to set up the hash. Also, you can use the quote words operator qw{ ... } to set up those keys that don't contain spaces to save keep typing quote marks. First let's set up the list of keys

use strict; use warnings; # Set up the keys that contain no spaces. # my @listOfGoodwords = qw{ mhm right well yeah sure good ah okay yep hm definitely alright 'm'm oh my god wow uhuh exactly yup mkay ooh cool uh fine true hm'm hmm yes absolutely great um so mm weird huh yay maybe eh obviously correct awesome really interesting ye-}; # Now add those keys that do contain spaces. # push @listOfGoodwords, q{i see}, q{i mean}, q{i know}, q{i think so};

Note that the q{ ... } is the same as using single-quotes whereas qq{ ... } is the same as double-quotes. Variables and character escapes like \n for newline interpolate in double-quotes but not in single-quotes. It is good practice only to use double-quotes when you require interpolation and to use single-quotes at all other times.

Now that we have the list we construct the hash, either with a foreach

my %Goodwords; foreach my $key (@listOfGoodwords) { $Goodwords{$key} = 1; }

or with a map

my %Goodwords = map {$_ => 1} @listOfGoodwords;

The map might look a little strange but all it is doing is passing each key in @listOfGoodwords into the map from the right (items passed into a map are held in the $_ variable) and passing two things, the key and value 1, out of the map to the left, thus populating the hash.

I hope this is of use to you.

Cheers

JohnGG

Update: Corrected typo in explanation of the map


In reply to Re: minimal response program code problem by johngg
in thread 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.