Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Re: I'm confused with Bitwise Operators

by mephit (Scribe)
on Jun 07, 2002 at 21:51 UTC ( [id://172684]=note: print w/replies, xml ) Need Help??


in reply to Re: I'm confused with Bitwise Operators
in thread I'm confused with Bitwise Operators

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://172684]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2024-04-19 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found