I've put together a simple script (module, really) that implements a REPL for perl. I'm sure most are familiar with the term, but for those that aren't, the idea is that the script reads an expression from the user, evaluates the expression, and finally, prints the result. The script then repeats the process.

Some trivial examples:

iperl> join " ", sort qw( squash apple turnip ) = apple squash turnip iperl> 8576275 / 3326 * 5.5 = 14182.0542693927 iperl> sub double { my $n = shift; $n * 2 } iperl> double 2 = 4 iperl> double double double 2 = 16 iperl>

I've found it to be invaluable for testing small snippits of code, calling methods in package modules, and benchmarking subroutines and module load times.

I'm considering submitting this to CPAN but I'm hesitating. I'm hesitating because I haven't seen anything like it there and it's the sort of thing that a lot of programming languages either ship with, or acquire quickly (examples: ruby, python, haskell), so I feel like there should already be an implementation (or six) out there that everyone's using.

Anyways, if you fine folks think this will be useful, I'd love to hear your suggestions on how to improve the interface and the implementation. I haven't packaged up the source code into an easily digestable tarball yet, but the POD documentation is available here.

On the other hand, if I'm re-inventing a wheel, please direct me to the original prototype. I'm sure it rolls better. :)


BTW, this is my first post. I apologize if it's in the wrong section or is generally un-monklike.

In reply to 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.