I wonder if an explanation could be provided for those of us who watch in awe...

Awe? You should look in the Obfuscation section some time and see truly obfuscated code. But basically this is what it does: first, it sets $= to an environment variable that (at least under Apache) indicates the length of the POSTed content, if any. Then, using the trinary conditional operator (foo ? bar : baz) it either reads the POSTed content from standard input (if there is any) or otherwise grabs the GET query string from another environment variable. Either way, it's now got whatever input is coming from the browser, which it then splits on ampersands (the standard CGI field separator), feeding the resulting list into the foreach loop. (I spelled foreach as for for brevity, a standard Perl Golf technique.) So, each time through the foreach loop you've got what amounts to the part of a CGI query between ampersands (or between the beginning and the first amp, or between the last and the end). The body of the loop undoes the character encoding that CGI does and splits it into a name/value pair. (CGI separates the name from the value with =.) The name and value get assigned to $: and $, respectively, but that's just temporary, since the very next statement uses these variables as a key/value pair which it stores in the %_ hash. I'll let you look up the special variables $\ and $/ if you don't know; the former is used for its special magic, and the latter is used for its default value. Anyway, the map turns the list of keys into a list of table rows with the keys and their respective values interpolated, and the whole thing gets sent to the browser. HTH.HAND.


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

In reply to Re: the search string and me by jonadab
in thread the search string and me by deveyus

Title:
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, 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:
    & &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.