A Simple Perl REPL

The easiest way to run a REPL in modern Perl is to invoke the debugger using an arbitrarily evaluated expression.

perl -d -e 0

You can then enter something like:

print "Hello!"

and watch it execute.

I prefer one that I wrote ages ago. It’s not too complicated and it meets my needs.

# repl.pl
# A simple REPL for Perl
# Copyright (c) 2014 by Jim Lawless (jimbo@radiks.net)
# MIT / X11 license
# See: http://www.mailsend-online.com/license2014.php
$t="\"Jimbo's Perl REPL\"";
while($t) {
   chomp $t;
   print eval($t),"\n";

I like mine because I can just enter in an expression … like 25*45 … and I can view the evaluated output. Well, I probably like mine because I’ve used it for such a long time.

To exit repl.pl, type:


About Jim Lawless

I've been programming computers for about 36 years ... 30 of that professionally. I've been a teacher, I've worked as a consultant, and have written articles here and there for publications like Dr. Dobbs Journal, The C/C++ Users Journal, Nuts and Volts, and others.
This entry was posted in Programming and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s