Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
It is no fun to write something you think is clever, unless you can show off with all the nitty-gritty. I was really hoping that someone bored enough would attempt to decode this one, but I decided to post a spoiler myself instead. Hopefully, some people will enjoy the "tricks" I tried to employ - almost all of them are misdirections, trying to make you beleive something else is happening. Did it work? Inquiring minds want to know... anyways, thanks for letting me waste some of your time. Keep on making unmaintainable code out there. :)
#!/usr/bin/perl -wl0040
These switches sets some special variables for me, which I will be using later. It sets $/ to a newline character, and $\ to a space character. See perlrun for details.
use vars qw( $ARG );
Minor thingy that will not fool many, but I don't like being sloppy, can I avoid it; this has no actual effect, but tries to hide the fact that use English; aliases $_ to $ARG.
$ARG = qr(

Here is a fun part. This looks very much like a hairy regular expression, yes? Well, I am not gonna use it as a such. Actually, I am using qr instead of q - I am gonna use $ARG as a plain string. I also use the slashes at the start and end (marked with blue) to make it look even more like a regular expression - in reality, they would probably break your otherwise valid regexp if you add them. I will get back to this later, though.

So, what about this match then?

($_=~s/$ARG/JAPH/ ||
  s/(\W)/\$$1/g && s/\$(\s)\$//g && s'([^/]+)'#$1\')
    or warn "No match!";	
When you have figured out that $_ and $ARG are the same, you will expect this to match, and the rest of the line to not execute. Also, if you are a bit gullible, you might suspect that the JAPH part has something to do with the final output. But if you use this "regexp" as a string, it will look like this:

Which will not match the regexp that it forms, so in reality it could just as well say:
(0 || s/(\W)/\$$1/g && s/\$(\s)\$//g
  && s'([^/]+)'#$1\') or warn "No match!";	
($_=~s/$ARG/JAPH/ || s/(\W)/\$$1/g &&
  s/\$(\s)\$//g && s'([^/]+)'#$1\') or warn "No match!";	
This part is straightforward: it simply adds a dollarsign ($) in front of every non-word character, producing:
$       $
$ $ $/$^C$^C$^C$^P$\$\$\$[$^D$"$\$[$^P$^C$"$"0$"$\0$/$"$"$\
Notice the highlighted part, because next regexp is just there to take that part out, with the newline. No magic. :)
($_=~s/$ARG/JAPH/ || s/(\W)/\$$1/g && s/\$(\s)\$//g &&
  s'([^/]+)'#$1\') or warn "No match!";	
($_=~s/$ARG/JAPH/ || s/(\W)/\$$1/g && print
  && s/\$(\s)\$//g && s'([^/]+)'#$1\') or warn "No match!";	

print qq($') && eval;
The highlighting should explain it - most would expect that I am matching something (actually, everything up till the first forward slash), and then adding a '#' in front of it. And since everything (mostly) seems to close alright, and we even have a warning in case something goes wrong, this should be it. But in reality, I am substituting everything up till said slash with the beginning of the next line too. See the green highlights to see which outer parenthesis actually match too. This makes our $_ look like this at the moment:
 #$1') or warn "No match!";

print qq($/$^C$^C$^C$^P$\$\$\$[$^D$"$\$[$^P$^C$"$"0$"$\0$/$
Which, when evaled, of course interpolates all these variables. Depending on which variables, they have different defaults (they are perl special vars), most of them zero, some are empty (just for show) and like I mentioned in the beginning, I also set $/ to a newline character, and $\ to space. This also made it possible to make \/ look like I was escaping slashes in the "regexp". So in reality, this code looks like this:
print "\n0000   00  000  0  0 \n   0  0  0 0  0 0  0 \n   
0  0000 000  0000 \n   0  0  0 0    0  0 \n000   0  0 0   
 0  0\n";
Which, of course, will print:
0000   00  000  0  0
   0  0  0 0  0 0  0
   0  0000 000  0000
   0  0  0 0    0  0
000   0  0 0    0  0
Please point out if something didn't make sense, was unclear (or somehow wrong), and I'll of course fix it. Any comments also very much appreciated (thanks grinder!).
You have moved into a dark place.
It is pitch black. You are likely to be eaten by a grue.

Edit: chipmunk 2002-02-28

In reply to SOLUTION: Amazing Regexp Grinder (ARG) by Dog and Pony
in thread Amazing Regexp Grinder (ARG) by Dog and Pony

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (9)
    As of 2018-03-20 14:51 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (254 votes). Check out past polls.