Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  DEVEL::REPL (3)

.ds Aq ’


Devel::REPL - a modern perl interactive shell



version 1.003026


  my $repl = Devel::REPL->new;
  $repl->load_plugin($_) for qw(History LexEnv);

Alternatively, use the ’’ script installed with the distribution



This is an interactive shell for Perl, commonly known as a REPL - Read, Evaluate, Print, Loop. The shell provides for rapid development or testing of code without the need to create a temporary source code file.

Through a plugin system, many features are available on demand. You can also tailor the environment through the use of profiles and run control files, for example to pre-load certain Perl modules when working on a particular project.


To start a shell, follow one of the examples in the SYNOPSIS above.

Once running, the shell accepts and will attempt to execute any code given. If the code executes successfully you’ll be shown the result, otherwise an error message will be returned. Here are a few examples:

 $_ print "Hello, world!\n"
 Hello, world!
 $_ nosuchfunction
 Compile error: Bareword "nosuchfunction" not allowed while "strict subs" in use at (eval 130) line 5.


In the first example above you see the output of the command (Hello, world!), if any, and then the return value of the statement (1). Following that example, an error is returned when the execution of some code fails.

Note that the lack of semicolon on the end is not a mistake - the code is run inside a Block structure (to protect the REPL in case the code blows up), which means a single statement doesn’t require the semicolon. You can add one if you like, though.

If you followed the first example in the SYNOPSIS above, you’ll have the History and LexEnv plugins loaded (and there are many more available). Although the shell might support up-arrow history, the History plugin adds bang history to that so you can re-execute chosen commands (with e.g. !53). The LexEnv plugin ensures that lexical variables declared with the my keyword will automatically persist between statements executed in the REPL shell.

When you use any Perl module, the import() will work as expected - the exported functions from that module are available for immediate use:

 $_ carp "Im dieeeing!\n"
 String found where operator expected at (eval 129) line 5, near "carp "Im dieeeing!\n""
         (Do you need to predeclare carp?)
 Compile error: syntax error at (eval 129) line 5, near "carp "Im dieeeing!\n""
 BEGIN not safe after errors--compilation aborted at (eval 129) line 5.

 $_ use Carp

 $_ carp "Im dieeeing!\n"
 Im dieeeing!
  at /usr/share/perl5/Lexical/ line 327

To quit from the shell, hit Ctrl+D or Ctrl+C.

  MSWin32 NOTE: control keys wont work if TERM=dumb
  because readline functionality will be disabled.

    Run Control Files

For particular projects you might well end up running the same commands each time the REPL shell starts up - loading Perl modules, setting configuration, and so on. A run control file lets you have this done automatically, and you can have multiple files for different projects.

By default the program looks for $HOME/, and runs whatever code is in there as if you had entered it at the REPL shell yourself.

To set a new run control file that’s also in that directory, pass it as a filename like so:

 system$ --rcfile myproject.pc

If the filename happens to contain a forward slash, then it’s used absolutely, or realive to the current working directory:

 system$ --rcfile /path/to/my/project/repl.rc

Within the run control file you might want to load plugins. This is covered in The REPL shell object section, below.


To allow for the sharing of run control files, you can fashion them into a Perl module for distribution (perhaps via the CPAN). For more information on this feature, please see the Devel::REPL::Profile manual page.

A Standard profile ships with Devel::REPL; it loads the following plugins (note that some of these require optional features — or you can also use the Minimal profile):
o Devel::REPL::Plugin::History
o Devel::REPL::Plugin::LexEnv
o Devel::REPL::Plugin::DDS
o Devel::REPL::Plugin::Packages
o Devel::REPL::Plugin::Commands
o Devel::REPL::Plugin::MultiLine::PPI
o Devel::REPL::Plugin::Colors
o Devel::REPL::Plugin::Completion
o Devel::REPL::Plugin::CompletionDriver::INC
o Devel::REPL::Plugin::CompletionDriver::LexEnv
o Devel::REPL::Plugin::CompletionDriver::Keywords
o Devel::REPL::Plugin::CompletionDriver::Methods
o Devel::REPL::Plugin::ReadlineHistory


Plugins are a way to add functionality to the REPL shell, and take advantage of Devel::REPL being based on the Moose object system for Perl 5. This means it’s simple to ’hook into’ many steps of the R-E-P-L process. Plugins can change the way commands are interpreted, or the way their results are output, or even add commands to the shell environment.

A number of plugins ship with Devel::REPL, and more are available on the CPAN. Some of the shipped plugins are loaded in the default profile, mentioned above. These plugins can be loaded in your $HOME/ like:

  load_plugin qw( CompletionDriver::Global DumpHistory );

Writing your own plugins is not difficult, and is discussed in the Devel::REPL::Plugin manual page, along with links to the manual pages of all the plugins shipped with Devel::REPL.

    The REPL shell object

From time to time you’ll want to interact with or manipulate the Devel::REPL shell object itself; that is, the instance of the shell you’re currently running.

The object is always available through the $_REPL variable. One common requirement is to load an additional plugin, after your profile and run control files have already been executed:

 $_ $_REPL->load_plugin(Timing);
 $_ print "Hello again, world!\n"
 Hello again, world!
 Took 0.00148296356201172 seconds.


In addition to the prerequisites declared in this distribution, which should be automatically installed by your CPAN client, there are a number of optional features, used by additional plugins. You can install any of these features by installing this distribution interactively (e.g. cpanm --interactive Devel::REPL).
o Completion plugin - extensible tab completion
o DDS plugin - better format results with Data::Dump::Streamer
o DDC plugin - even better format results with Data::Dumper::Concise
o INC completion driver - tab complete module names in use and require
o Interrupt plugin - traps SIGINT to kill long-running lines
o Keywords completion driver - tab complete Perl keywords and operators
o LexEnv plugin - variables declared with my persist between statements
o MultiLine::PPI plugin - continue reading lines until all blocks are closed
o Nopaste plugin - upload a session\’s input and output to a Pastebin
o PPI plugin - PPI dumping of Perl code
o Refresh plugin - automatically reload libraries with Module::Refresh


Matt S Trout - mst (at) (<>)


Stevan Little - stevan (at)
Alexis Sukrieh - sukria+perl (at)
mgrimes - mgrimes (at) cpan dot org
Shawn M Moore - sartak (at)
Oliver Gorwits - oliver on
Andrew Moore - <>
Norbert Buchmuller <>
Dave Houston <>
Chris Marshall
Karen Etheridge <>


This library is free software under the same terms as perl itself
Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 DEVEL::REPL (3) 2014-07-16

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.