First, you should be using use strict; and use warnings;. Second you shouldn't be quoting integers:

my $found = 0; ... if ($found == 0){... # or better: if (! $found){... # or for truth: if ($found){...

Now, the way you have things set up, won't do an exact match, so if someone states an org as "hi", you'd match on "chia", "chitchat" etc.

It's very hard to tell what's failing without you specifying some examples of what people are sending in, and the contents of your @orgs array.

In fact, after re-reading your post, we'll absolutely need to know what the contents of both are... do the words in the dictionary contain special chars such as commas, periods etc. Does the $organization coming in? If the dictionary has one word per line and you're receiving things like Company, LLC, you'll have to split the $organization up, clean it if necessary, then change the logic. Depending on the above, the following example may not (or probably won't) work.

Please provide us with some more details.

...

I'd recommend grep for this job. That way, your @orgs don't get split into things like "Company," and "LLC". The whole "Company, LLC" will have to match, exactly:

use warnings; use strict; my $organization = "thre"; my @orgs = qw (one two three four); error_suspect_org() if ! grep {$organization eq $_} @orgs; sub error_suspect_org { die "not a valid org!\n"; }

In reply to Re: Creating a whitelist by stevieb
in thread Creating a whitelist by htmanning

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.