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
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.