I have a longer script 'pash', that uses Term::ReadLine for history support. The only thing about 'pash' is that you hit enter twice - this allows multi-line entries.

#!/usr/bin/perl # # pashn - simple perl shell with Readline support # $Id: pashn,v 1.1 2003/11/05 12:57:48 banjo Exp $ # # copyright 2003 Billy Naylor # banjo@actrix.co.nz # # This is GPL software... # See the GNU General Public Licence # http://www.fsf.org/licenses/gpl.txt # use Term::ReadLine; my $help = <<EOH; pashn is a simple perl shell, it allows you to type in raw perl, fragments and subs. You can also run shell commands by appending the command with a bang! However 'my' and 'local' will only work inside a single statement, and so multiline code can be entered you must hit return twice. But in return, Term::ReadLine is here to give us history and non-destructive backspaces, and multiline editing, and bash or vi keybindings, and of course you can easily 'use' oodles of CPAN modules, ? EOH my $terminal = Term::ReadLine->new('PASH'); $terminal->ornaments(0); $terminal->MinLine(undef); $| = 1; my $prompt = "pashn; "; while () { my $editbuffer = $terminal->readline( $prompt ); while () { my $b = $terminal->readline(''); last unless $b; $editbuffer .= "$b\n"; } chomp $editbuffer; $terminal->addhistory($editbuffer); if ($editbuffer =~ s/^\s*\!//) { print qx|$editbuffer|; next; } eval ("$editbuffer"); print $@ if $@; print "\n"; next; } sub help { print $help } sub quit { exit 0 } # thankyuoverymuchGoodnight exit 0;

In reply to Re^2: Interactive perl by banjo
in thread Interactive perl by Securiger

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.