Nifty!

Not just for what it does and how it does it, but because it's probably the first obfuscated code I've been able to figure out on my own. However, some things were just assumptions or guesses.

So, in an attempt to help me really wrap my mind around this, build up my hubris, and learn something; I would appreciate it if (a|some) more knowledgable monk(s?) could (explain|verify) the following magic:

1) I think I figured this one out. At first I was confused about the 4 digit sequences. I was thinking the ones that started with a zero were octal, and was coming up with an unintelligible character sequence. But then I recalled something about the default match delimiters acting like double quotes. I read elsewhere on this site that a "number" like 0100 is octal, but "0100" is decimal. So apparently the captured data in the match effectively is double quoted, in this case insuring the numbers are decimal?

2) I seem to recall reading, but can't find it anywhere right now; that in an expression like

$1>=1000&&1000-$1||$1*1

it's value is the last thing evaluated. That expression can be re-written as
($1>=1000)     &&    (1000-$1)     ||     ($1*1)

so if $1>=1000, it has to evaluate 1000-$1, and can stop there since it's satisfied the ||, and the value of the expression is 1000-$1. If $1<1000 it won't bother with 1000-$1, and then evaluate $1*1, so the value of the expression is $1. At least, from my reading of the description of associativity, that's the order in which I presume it evaluates the terms. So, I take it, one of the ramifications of associativity is determining the ultimate value of a complex expression?

3) I've never seen a do{} with the while inside the braces, is this the same effect as having it immediately after them?

4) I've never seen a block before a for. Is this a similar idiom to reversing an if and letting you do this?

print $message if $verbose;

5) I copied the code into my text editor and put spaces in between each 4 digit sequence of the data while I was trying to figure it out. After I figured it out, I saved it and ran it, but it didn't work. I had to remove the spaces. The \G saves your place in the data, but it doesn't act like an anchor does it? I mean, if there's now a space before the next set of 4 digits, shouldn't it just skip the space to get to the digits? It didn't seem to.

Sorry to go on so long, but I've found this to be a site of great knowledge, and am hoping to learn much here.

TheEnigma


In reply to Re: japh with re by TheEnigma
in thread japh with re by Velaki

Title:
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, details, 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, summary, 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.