Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Thanks kenneethk

It took me a while to figure it out. I am putting your response in more explicit terms for neophytes like myself.

$Str1 = "AAAACCCCGGGGTTTT"; $Str2 = "ACGTACGTACGTACGT"; $cmp = $Str1^$Str2; $cmp |= '0' x length($cmp); print "$Str1\n"; print "$Str2\n"; print "$cmp\n";
# What is ‘|=’ doing? This is bitwise ‘or’. Does ‘or’ on left side and right side (right side value is ‘0’ or 00110000). Puts result of ‘or’ in left side. Originally, the value in $cmp for “A” ^ “G” was 00000110 (= 6) – this is ‘Acknowledgement’ – this is not a printable character.

By doing the ‘or’ with “0” (00110000 = 48) you convert ‘6’ to ‘6’ + ‘48’ = ‘54’ – this is the value for the character 6. So, $cmp looked empty because all of the values are for non-printable characters.

A = 01000001
G = 01000111
^ 00000110 = 6 ‘Acknowledgement’

left 00000110
‘0’ 00110000
| (or) 00110110 = 54 ‘character 6’


A = 01000001
T = 01010100
^ 00010101 = 21 ‘Negative Acknowledgement’

left 00010101
‘0’ 00110000
|(or) 00110101 = 53 ‘character 5’

Thanks again for your help,

romano (aka KennB)

In reply to Re^2: bitwise string operator by romano
in thread bitwise string operator by Anonymous Monk

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (3)
    As of 2019-01-19 21:15 GMT
    Find Nodes?
      Voting Booth?
      After Perl5, I'm mostly interested in:

      Results (343 votes). Check out past polls.

      • (Sep 10, 2018 at 22:53 UTC) Welcome new users!