shawn wilson wrote:
On Sat, Apr 9, 2011 at 3:29 PM,<sono...@fannullone.us>  wrote:

It is detecting but not testing if any particular 2 words are in a
text field and I think that's what you explained you were testing for.

        Sorry if my first post was misleading.  Those were just some examples.  
I'm looking only for an occurrence of _any_ two words in that list, not a 
particular combination.  Though the most common combo is a PO Box and a street 
address.

You can say: if (/box/i&&  /street/i) {
rather than the more complex:  if ($str =~ /box/i&&  $str =~ /street/i)

my $address_count = () = $str =~ /box|street|avenue|lane|apo/ig;

what does print $var = () = $str =~ /regex/; do?
particularly the '= () ='?


per the question, maybe something like this:
my @match = [ qr/one/i, qr/two/i, qr/etc/i ];
my @words = split /[^\s]+/, $fields;

/[^\s]+/ can also be represented as /\S+/.

But that stores whitespace strings in @words, not actual words.



John
--
Any intelligent fool can make things bigger and
more complex... It takes a touch of genius -
and a lot of courage to move in the opposite
direction.                   -- Albert Einstein

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to