There is now a webpage for the hack.

And

eval('0 and eval(\'def length(x) end\')'); 0 and length <<2;
has been simplified to
0 and eval('false') and length <<2;
Perl and python consider 0 false, so "0 and" is a test for ruby. There is no point in ruby actually executing length, we just need the heredoc, so we add an always failing test for ruby's false. To avoid a perl unquoted string warning, we wrap it in an eval. Which may or may not be faster than ruby actually calling a do nothing "def length(x) end" ruby function, but it avoids namespace pollution. The core concept is that the token length is serving both as a variable in a bitshift for python, and as a function with a heredoc argument for perl and ruby. The heredoc jumps over pythons """ multi-line string token, which the perl parser doesnt like. The name "length" was chosen because perl needs to have seen the function declared in order to parse the line correctly, and length() seemed innocuous. So that's the thinking behind this fragment.

Still more work to be done.

Thanks for the comments.


In reply to Re: Source files which work with perl, python, and ruby [webpage] by mnc
in thread Source files which work with perl, python, and ruby by mnc

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.