Hello all,

The other day I was playing around with B::Deparse and its brethren as a debugging tool with a colleague. We were using it to have a look at the bug that I posted about in Funkyness with closures.... From there we started discussing modifiers and using this code

use strict; use warnings; my $cond=1; my $i=1 for $cond; for ($cond) { my $j=1; }
(called as perl -MO=Deparse cond.pl) We got the following:
my $cond = 1; foreach $_ ($cond) { my $i = 1; } foreach $_ ($cond) { my $j = 1; }
Which is of course _wrong_. My colleague used this to supposedly _prove_ that the modifier form is identical to the non-modifier form. I disagreed but had nowhere to go until we appended the following lines to the original script and then uncommented them one at a time. Guess which ones fail
#comments added on update #print "$i/n"; # Works for input code, not output code #print "$j/n"; # Fails for both
Begin Update
I should have been more specific. The point here is the original two loops have different scoping effects. But, I presume because the output of deparse is from a stage after these effects are determined. I dont know and I'd like to understand it better. End Update

Anyway, there are some funky modules under the B branch that are worth having a look at. Id be interested as to how the other monks out the find them usefull (or not) and what tricks and tips (like the above) there are to know.

To be honest any thoughts or comments at all about this stuff would be very welcome. And while I'm trawling the communal wisdom, any thought on using -d under NT would be apreciated as well.

Somewhat incoherent post, sorry...

Yves
--
You are not ready to use symrefs unless you already know why they are bad. -- tadmc (CLPM)


In reply to Regarding B::Deparse by demerphq

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.