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??
Most of the second and third lines are devoted to initializing $a (and $| as a side effect):
||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB=' .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g
The two unpacks generate an array consisting of the number 14417713111218131332253147132969324349431334211136532212511512172112293224231453242. The decimal digits of this number are then extracted via =~/./g and used to run-length decode a bit string 1000011110... via map--$|x$_. Since the number of decimal digits is odd, the last value of $| is 1.

After we remove the initialization code and the trailing #JAPH, comment we have:

{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr (($a)x2,$_,256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}
The expression substr(($a)x2,$_,256) produces a copy of the bitstring rotated left by $_ characters (assuming 0<=$_<256). The map sets $_ to 7 and 249 producing the bitstring rotated left by 7 characters and rotated right by 7 characters respectively. These bitstrings are passed to sub{pop^pop} which XORs them together. They are then further XORed with the original bitstring.

The unpack separates the bitstring into groups of 8 bits, and the pack converts the first 25 groups into characters. The substitution converts everything but letters and commas into spaces. The next statement sets the output line ending to a CR unless the first letter of $_ is a J in which case it sets it to the input line ending. The final redo starts over at the beginning of the block.

The rotate-and-XOR operation used in this program has period 128, so every 128 iterations the JAPH string is printed. The initial bitstring becomes the JAPH string after 67 iterations. I note with interest that the bytes after the end of the JAPH string are not all binary zeros.

In reply to Re: My 1st post (japh) by jdalbec
in thread My 1st post (japh) by blazar

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 sharing their wisdom with the Monastery: (9)
As of 2024-04-23 08:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found