Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Is it possible to find the number of matching and non-matching positions in strings using perl code?

by moritz (Cardinal)
on May 11, 2012 at 12:25 UTC ( #969995=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Is it possible to find the number of matching and non-matching positions in strings using perl code?
in thread Is it possible to find the number of matching and non-matching positions in strings using perl code?

But the for loop just obfuscates things without adding anything at all.

It adds generality beyond three strings to compare.

Also, calling your variable $mask is questionable as you don't really intend to use it as a mask.

So what do you suggest instead? Your usage of $bits isn't any better, because you don't care about bits, but bytes. But $bytes also wouldn't explain the purpose of the variable.


Comment on Re^3: Is it possible to find the number of matching and non-matching positions in strings using perl code?
Select or Download Code
Re^4: Is it possible to find the number of matching and non-matching positions in strings using perl code?
by sauoq (Abbot) on May 11, 2012 at 12:53 UTC
    It adds generality beyond three strings to compare.

    I might give you that if you wrote it that way. for ($b, $c) isn't any more general than my single statement. We'd both have to go change our code if we suddenly had to compare 4 strings.

    So what do you suggest instead? Your usage of $bits isn't any better, because you don't care about bits, but bytes.

    I'm not suggesting it's a good name for anything more than a throwaway example, but I wouldn't say it isn't any better. I do actually care about bits as I'm using it with bitwise operators. And the real point is that calling it $mask implies that you intend to use it as a mask. When you don't, confusion results.

    -sauoq
    "My two cents aren't worth a dime.";

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (14)
As of 2014-09-16 15:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (33 votes), past polls