The program

while( true )
{
print "gimme:  ";
$line=<>;
$value=eval( $line );
$error=$@;
if( $error ne "" ){ print $error; }else{ print "$value\n"; }
}
The reader is respectfully invited to select and copy the program, and to paste it into an empty file, and to save the file for use with the Perl language. Actually, it is possible and probable that the reader has already invented this program herself.

Some explanation

There seem to be two sizes of Perl REPL programs, too small and too large. The too small are only one line, and they work poorly. The too large have to be downloaded and installed, and they are monstrously big and complicated for the little tasks I have in mind.

All I want is to start the program and see the prompt

gimme:  
and type in a Perl expression that I wish to be evaluated
gimme:  sin(.1)
and push the “Enter” key. In this instance the program will print
0.0998334166468282
Actually, the program does not prompt in red. I just did that in the present file for easier reading. The word “gimme” is a two-syllable contraction in American English for “give to me.” The “g” has a hard sound, not soft. The user can of course change the program to use a more professional-looking prompt, or a prompt in a different language.

The program is not restricted to expressions. Any Perl statements are permitted, but they must not take more than one line each. Here is an example:

gimme:  $x=1.23
gimme:  $y=(exp($x)+exp(-$x))/2
gimme:  sqrt($y)
It is permissible to put more than one statement or expression on a line, but the semicolon separator must then be used. Please do not use the “my” modifier unless a function is being built.

The easiest way to leave the program is to use

gimme:  exit

Claimed advantages

Some of the one-line Perl REPLs do not print all the error messages, and some of them require the use of the word “print.” REPLs in some other languages require semicolons or “Math.” prefices or both.

License, e-mail address, and revision date

All of the present file is in the public domain. Comments on all this, both constructive and destructive, come to me, Harold Kaplan,
       at        dot
smtw2gh  toadmail   com
This file is most recently revised on 25 June 2008.