Something else to consider: "distribution" (or lack thereof) of the binding operator. Note that $_ =~ (/A/ && /B/) is not equivalent to ($_ =~ /A/) && ($_ =~ /B/). The latter is what you would want.

Regarding the original poster's code:

$count++ if $_ =~ /\b$dst[0]\b/ && /\b$service[ +0]\b/;
This works only because $_ is being tested. Taking precedence into consideration (and the fact that m// works on $_ by default), this code is equivalent to
($_ =~ /\b$dst[0]\b/) && ($_ =~ /\b$service[+0]\b/);
If the data were in any other variable ($var, for example), and one just replaced $_ with $var in the OP's code, it would be equivalent to
($var =~ /\b$dst[0]\b/) && ($_ =~ /\b$service[+0]\b/);
which isn't What You Want.

Just my observations. HTH.

--

There are 10 kinds of people -- those that understand binary, and those that don't.


In reply to Re: Re: I'm confused with Bitwise Operators by mephit
in thread I'm confused with Bitwise Operators by Anonymous Monk

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.