http://www.perlmonks.org?node_id=114760

$a=q-q=a$ Cal Henderson Techincal Director Emap Digital New Projects e: cal.henderson@emap.com t: 020 7868 7543 m: 07899 835995 no unsolicted commercial email, ok! -;$b=59;while('64aa22632f626f63913d8f3199583a6571c82d227fe1 07420'=~/(..)/g){$b+=-100+hex$1;print((split(//,$a))[$b]);}

Replies are listed 'Best First'.
Re: yet another email sig
by higle (Chaplain) on Sep 27, 2001 at 20:48 UTC
    Very nice! And very original! So simple, and yet, so confusing!

    Let's see if I can dissect it a bit:
    $a=q-q=a$
    The first line declares $a as a variable, and assigns it a string, using the q operator with "-" as a delimiter. The following string:
    q=a$ Cal Henderson Techincal Director Emap Digital New Projects e: cal.henderson@emap.com t: 020 7868 7543 m: 07899 835995 no unsolicted commercial email, ok!
    is what is used as the pool of letters to write the program's output, "just another Perl hacker".

    Then you've got the closing "-" delimiter, followed by the ";" closing out that statement. The next bit is the fun part:
    $b=59; while('64aa22632f626f63913d8f3199583a6571c82d227fe107420' =~ /(..)/g) { $b += -100 + hex $1; print((split(//,$a))[$b]); }
    $b is initialized with the value 59, and the while statement executes a regex search on the string 64aa22632f626f63913d8f3199583a6571c82d227fe107420 which basically grabs every two characters in that string, and stores them to the special variable $1.

    Inside the for loop, the value of $b is augmented using the following logic:
    • find the decimal value of the hexadecimal number contained in $1
    • subtract 100 from it.
    • add that number to the existing value of $b
    So, from the start, $b==59, the regex grabs the hexadecimal number "64", converts it to 100 in decimal, subtracts 100 from it, and adds the value to $b, resulting in the value 59.

    The next bit is interesting. The split operator is called on the big string contained in $a, splitting it by '', thus creating a big array composed of each individual character in the string, including spaces. [$b] is appended after the parenthesized split statement, thus turning the current value of $b into an array index, plucking the letter in that position out of the temporary array created by the split statement, and sending it to the print statement.

    Perhaps I over analyzed this one, but I had fun taking it apart and looking at it's components!

    ++iamcal!

    higle
Re: yet another email sig
by kschwab (Vicar) on Oct 01, 2001 at 01:03 UTC
    Hate to nit, but "Techincal Director" ? :)

    I don't normally point out this kind of thing, but since it's being used as a char pool...

      urgh, my spelling sucks.

      but in any case, my name's cal so i'm a techin-cal director :)