You get a feather in your obfuscated code contest cap when you are able to write code that doesn't work when deparsed. Yes, it's possible to foil deparse. Why? Only perl itself can parse Perl.

In the case of your example, how would you want deparse to deparse that construct? Something more like this?:

my $d = 'Shakespeare is the food'; foreach ( $d ) { s/food/bard/; }

The problem is that of lexical scoping, and that of deparse trying its damndest to refrain from using 'for' as a modifier. I would say that at best your nifty trick is just a trick worthy of use in obfu, but not in mainstream code. I believe that the behavior allowing it to work in the case of the 'for' modifier is not defined, and thus may change in future Perl refinements. It's certanly not discussed directly in perlsyn, though perlsyn does mention that using my() on the left hand side of a conditional modifier yields undefined behavior.


Dave


In reply to Re: Deparse broken or just misunderstood? by davido
in thread Deparse broken or just misunderstood? by Roy Johnson

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.