Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I found this post on-line and I am not clear exactly what is going on.

“…you will get a string of bytes with values zero and one, rather then the characters '0' and '1'. To make this printable just 'or' in a string of zeroes of the right length.”

$dd |= '0' x length $dd

I know what the result of this statement is but I am not sure exactly what (how) it is doing (it). I am comparing 2 strings (^) and when I do

$cmp |= '0' x length($cmp); # See rest of code below.

numbers magically appear and I can then see (print) what is in $cmp. So, what exactly does ‘or’ in a string of zeroes mean? Zeroes appear but so do other digits (“A” ^ “C” → 2). What does |= do? (or |= ‘0’) Is there some substitution occurring?

My code:
$Str1 = "AAAACCCCGGGGTTTT"; $Str2 = "ACGTACGTACGTACGT"; $cmp = $Str1^$Str2; $cmp |= '0' x length($cmp); print "$Str1\n"; print "$Str2\n"; print "$cmp\n";

**OUTPUT**

AAAACCCCGGGGTTTT

ACGTACGTACGTACGT

0265204764035730

grazie,

romano


In reply to bitwise string operator 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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-23 06:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found