After running your version of the code on my machine I notice a couple of differences between your results and mine. When you print out the results of the compiled and deparsed macro, you get...
MACRO (COMPILED & DEPARSED): while ($var3 < $cons4) { $body6; } continue { ++$var5 }
while I get...
MACRO (COMPILED & DEPARSED): $var1 = $cons2; while ($var3 < $cons4) { $body6; } continue { ++$var5 }
...I notice that the first line $var1 = $cons2; is missing in your report. And strangely enough there's a line is missing from your compilied and deparsed source code ...
SOURCE (COMPILED & DEPARSED): my $x; while ($x < 8) { my $f = fact($x); print "factorial($x)=$f\n"; } continue { ++$x } sub fact { $_[0] <= 0 and return 1; return $_[0] * fact($_[0] - 1); } '???';
vs. my machine
SOURCE (COMPILED & DEPARSED): my $x; $x = 0; while ($x < 8) { my $f = fact($x); print "factorial($x)=$f\n"; } continue { ++$x } sub fact { $_[0] <= 0 and return 1; return $_[0] * fact($_[0] - 1); }
...the $x = 0; has gone missing. So this causes $reorder to differ...
REORDER: $var3 = $1;$cons4 = $2;$body6 = $3;$var5 = $4;
vs.
REORDER: $var1 = $1;$cons2 = $2;$var3 = $3;$cons4 = $4;$body6 = $5;$va +r5 = $6;
and is probably what causes the substitution match failure and thus you get the original code back. I don't know why lines would suddenly dissapear. Is it a buffering problem with the back-tick operator?

update:I'd try just running...

perl -MO=Deparse,-x9 -e'for($i=0;$i<10;$i++){$x++}'

...all by itself and see if it matches...

$i = 0; while ($i < 10) { ++$x; } continue { ++$i }
That's straight from 3rd edition camel p. 480. Anyone else have any ideas? BTW, I'm running perl 5.6.1 under Slackware Linux

In reply to strange differences... by sleepingsquirrel
in thread Playing with (macro/source-filter) fire by sleepingsquirrel

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.