Just in case it wasn't easy enough for beginners to figure out...
Spoilers follow:
|
I have removed any "filler" statements (i.e. $~=~112;) and comments. I have also formatted the script for readability and added in explanatory comments.
#!/usr/bin/perl -w
use strict;
# clear out $~
$~=~s/.*//;
sub ___{
# return this string
'chr(';
}
sub __{
# return this string
'print(';
}
sub _{
# foreach $_ (0 .. $#_) {
for (0..$#_) {
# append 'print(chr(' and the $_th element of @_ to $~
$~ .= __.___.$_[$_];
# append '))' to $@
$@ .= '))';
# if $_ matches the value of $#_ then you are done
last if /$#_/;
# append a '+' to $~
$~ .= '+';
}
# the double quoted string "$~$@;" results in a value of
# print(chr(9+print(chr(71+print(chr(79+print(chr(64+print(chr(74)))
+)))))));
# eval the string to produce the output
eval "$~$@;";
}
# call the _ subroutine with the values given
# they are in octal so change them to decimal
# and they are (9,71,79,64,74)
_(0011,0107,0117,0100,0112);
|