Thanks for the feedback, people.

I'll more than likely just keep my implementation to myself and continue to improve on it. It's unlikely that it offers any additional features that would make it a more compelling solution than the debugger or some of the other scripts/one-liners mentioned here, and if and when I does, I'm sure it will be superseded by whatever perl6 ships with. :) It's still a fun bit of code to tinker with, though.

Anyways, I would like to show how I implemented a couple of the features with the intent of finding out if there's a better way. If this is falling out of the realm of a "meditation", please feel free to ignore or delete this node.

The first 'feature' is the ability to define variables with my() and have them continue to exist outside the scope of the eval block.

The module uses a command filtering system. Users can register new filters by way of a "mixin" module, or with their ~/.iperlrc file.

The "globalvars" mixin module turns top-level lexical variables into package globals by changing my() to our() before your code is executed. Kinda lame, huh? :) Anyways, the effect is that you can write code like this:

iperl> my $foo = "abc" = abc iperl> do { my $bar = "def" } = def iperl> print $foo abc = 1 iperl> print $bar Use of uninitialized variable in...

Is there a more sane way to do this? Is it possible to safely promote a lexical variable to a scope one level up? Or perhaps, to some form of sandbox scratchpad that won't pollute the module's table (which this currently does)?

The other feature that I'd like some feedback on is the "benchmark" mixin. It can be used to benchmark each statement that's executed.

iperl> use IPerl::Mixins::Benchmark iperl> benchmark_on() iperl> use time_consuming_module 4 wallclock secs ( 1.58 usr + 0.19 sys = 1.77 CPU) iperl>

The module uses Hook::LexWrap to register pre and post routines. The pre routine creates a timer, and the post routine creates a second and displays the diff between the two.

Hook::LexWrap seems to work well for this, but I'm wondering if there's a better way? My goal is to keep the additional features as unobtrusive as possible and to effectively keep them out of the base IPerl.pm module.


In reply to Re^2: RFC: IPerl - Interactive Perl ( read-eval-print loop ) by mseabrook
in thread RFC: IPerl - Interactive Perl ( read-eval-print loop ) by mseabrook

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.