Test whether one string contains any of the words in another
<p>I have a Perl program code that pulls a description string from a hash.  </p>

<p>I have my variable <code>$ui</code> equal to the variable <code>$uniqueID</code>, but what I want is to return true if <code>$ui</code> <em>contains any words</em> in variable <code>$unqiueID</code>. But <code>=~</code> isn't working.</p>

<p>Is there a smart way of doing this?</p>

<pre><code>sub getDescription {

    my $uniqueID = shift;
    my $retval;
    my $ui;

    foreach my $key ( keys %HASHLIST ) {

        foreach $ui ( @{ $HASHLIST{$key}-&gt;{uniqueID} }) {

            if ( $ui eq $uniqueID ) {
                $retval = $HASHLIST{$key}-&gt;{description};
                last;
            }
         }

         last if $retval;
    }

    return $retval;
}
</code></pre>