This is interesting! I see your point! I'm trying more tests now...Got it I hope!

Update: Ok, my wonky guess is that the pattern match returns a null string (not undef) from the '!~' which in an if statement is FALSE of course!

I think the index function technique may be faster if you're not using other pattern matching metacharacters. Run below to see what I think may explain the problem.

use strict; my $exclude = 'middle_name pager zip'; my $lookfor='pager'; my $lookfor2='wonk'; # This would work without using pattern matching: # Note lc function used to ignore case! my $pos=index(lc($exclude),lc($lookfor),0); if ($pos > -1) {print "Found $lookfor !\n";} $pos=index(lc($exclude),lc($lookfor2),0); if ($pos == -1) {print "Cannot find $lookfor2 !\n";} print "\n"; my $look=($exclude =~ /$lookfor/gi); my $look2=($exclude =~ /$lookfor2/gi); my $notlook=($exclude !~ /$lookfor/gi); my $notlook2=($exclude !~ /$lookfor2/gi); print "'\$exclude =~ /$lookfor/gi' evaluates to '$look'\n"; print "'\$exclude =~ /$lookfor2/gi' evaluates to '$look2'\n"; print "'\$exclude !~ /$lookfor/gi' evaluates to '$notlook'\n"; print "'\$exclude !~ /$lookfor2/gi' evaluates to '$notlook2'\n"; __END__

..:::::: aquacade ::::::..


In reply to Re: This is just wonky... by aquacade
in thread This is just wonky... by Sullust

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.