Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: yet another email sig

by higle (Chaplain)
on Sep 27, 2001 at 20:48 UTC ( [id://115154]=note: print w/replies, xml ) Need Help??


in reply to yet another email sig

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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://115154]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2024-04-23 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found