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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |