1Devel::REPL(3)        User Contributed Perl Documentation       Devel::REPL(3)
2
3
4

NAME

6       Devel::REPL - A modern perl interactive shell
7

VERSION

9       version 1.003028
10

SYNOPSIS

12         my $repl = Devel::REPL->new;
13         $repl->load_plugin($_) for qw(History LexEnv);
14         $repl->run
15
16       Alternatively, use the 're.pl' script installed with the distribution
17
18         system$ re.pl
19

DESCRIPTION

21       This is an interactive shell for Perl, commonly known as a REPL - Read,
22       Evaluate, Print, Loop. The shell provides for rapid development or
23       testing of code without the need to create a temporary source code
24       file.
25
26       Through a plugin system, many features are available on demand. You can
27       also tailor the environment through the use of profiles and run control
28       files, for example to pre-load certain Perl modules when working on a
29       particular project.
30

USAGE

32       To start a shell, follow one of the examples in the "SYNOPSIS" above.
33
34       Once running, the shell accepts and will attempt to execute any code
35       given. If the code executes successfully you'll be shown the result,
36       otherwise an error message will be returned. Here are a few examples:
37
38        $_ print "Hello, world!\n"
39        Hello, world!
40        1
41        $_ nosuchfunction
42        Compile error: Bareword "nosuchfunction" not allowed while "strict subs" in use at (eval 130) line 5.
43
44        $_
45
46       In the first example above you see the output of the command ("Hello,
47       world!"), if any, and then the return value of the statement (1).
48       Following that example, an error is returned when the execution of some
49       code fails.
50
51       Note that the lack of semicolon on the end is not a mistake - the code
52       is run inside a Block structure (to protect the REPL in case the code
53       blows up), which means a single statement doesn't require the
54       semicolon. You can add one if you like, though.
55
56       If you followed the first example in the "SYNOPSIS" above, you'll have
57       the History and LexEnv plugins loaded (and there are many more
58       available).  Although the shell might support "up-arrow" history, the
59       History plugin adds "bang" history to that so you can re-execute chosen
60       commands (with e.g.  "!53"). The LexEnv plugin ensures that lexical
61       variables declared with the "my" keyword will automatically persist
62       between statements executed in the REPL shell.
63
64       When you "use" any Perl module, the "import()" will work as expected -
65       the exported functions from that module are available for immediate
66       use:
67
68        $_ carp "I'm dieeeing!\n"
69        String found where operator expected at (eval 129) line 5, near "carp "I'm dieeeing!\n""
70                (Do you need to predeclare carp?)
71        Compile error: syntax error at (eval 129) line 5, near "carp "I'm dieeeing!\n""
72        BEGIN not safe after errors--compilation aborted at (eval 129) line 5.
73
74        $_ use Carp
75
76        $_ carp "I'm dieeeing!\n"
77        I'm dieeeing!
78         at /usr/share/perl5/Lexical/Persistence.pm line 327
79        1
80        $_
81
82       To quit from the shell, hit "Ctrl+D" or "Ctrl+C".
83
84         MSWin32 NOTE: control keys won't work if TERM=dumb
85         because readline functionality will be disabled.
86
87   Run Control Files
88       For particular projects you might well end up running the same commands
89       each time the REPL shell starts up - loading Perl modules, setting
90       configuration, and so on. A run control file lets you have this done
91       automatically, and you can have multiple files for different projects.
92
93       By default the "re.pl" program looks for "$HOME/.re.pl/repl.rc", and
94       runs whatever code is in there as if you had entered it at the REPL
95       shell yourself.
96
97       To set a new run control file that's also in that directory, pass it as
98       a filename like so:
99
100        system$ re.pl --rcfile myproject.pc
101
102       If the filename happens to contain a forward slash, then it's used
103       absolutely, or realive to the current working directory:
104
105        system$ re.pl --rcfile /path/to/my/project/repl.rc
106
107       Within the run control file you might want to load plugins. This is
108       covered in "The REPL shell object" section, below.
109
110   Profiles
111       To allow for the sharing of run control files, you can fashion them
112       into a Perl module for distribution (perhaps via the CPAN). For more
113       information on this feature, please see the Devel::REPL::Profile manual
114       page.
115
116       A "Standard" profile ships with "Devel::REPL"; it loads the following
117       plugins (note that some of these require optional features -- or you
118       can also use the "Minimal" profile):
119
120       ·   Devel::REPL::Plugin::History
121
122       ·   Devel::REPL::Plugin::LexEnv
123
124       ·   Devel::REPL::Plugin::DDS
125
126       ·   Devel::REPL::Plugin::Packages
127
128       ·   Devel::REPL::Plugin::Commands
129
130       ·   Devel::REPL::Plugin::MultiLine::PPI
131
132       ·   Devel::REPL::Plugin::Colors
133
134       ·   Devel::REPL::Plugin::Completion
135
136       ·   Devel::REPL::Plugin::CompletionDriver::INC
137
138       ·   Devel::REPL::Plugin::CompletionDriver::LexEnv
139
140       ·   Devel::REPL::Plugin::CompletionDriver::Keywords
141
142       ·   Devel::REPL::Plugin::CompletionDriver::Methods
143
144       ·   Devel::REPL::Plugin::ReadlineHistory
145
146   Plugins
147       Plugins are a way to add functionality to the REPL shell, and take
148       advantage of "Devel::REPL" being based on the Moose object system for
149       Perl 5. This means it's simple to 'hook into' many steps of the R-E-P-L
150       process. Plugins can change the way commands are interpreted, or the
151       way their results are output, or even add commands to the shell
152       environment.
153
154       A number of plugins ship with "Devel::REPL", and more are available on
155       the CPAN. Some of the shipped plugins are loaded in the default
156       profile, mentioned above.  These plugins can be loaded in your
157       $HOME/.re.pl/repl.rc  like:
158
159         load_plugin qw( CompletionDriver::Global DumpHistory );
160
161       Writing your own plugins is not difficult, and is discussed in the
162       Devel::REPL::Plugin manual page, along with links to the manual pages
163       of all the plugins shipped with "Devel::REPL".
164
165   The REPL shell object
166       From time to time you'll want to interact with or manipulate the
167       "Devel::REPL" shell object itself; that is, the instance of the shell
168       you're currently running.
169
170       The object is always available through the $_REPL variable. One common
171       requirement is to load an additional plugin, after your profile and run
172       control files have already been executed:
173
174        $_ $_REPL->load_plugin('Timing');
175        1
176        $_ print "Hello again, world!\n"
177        Hello again, world!
178        Took 0.00148296356201172 seconds.
179        1
180        $_
181

OPTIONAL FEATURES

183       In addition to the prerequisites declared in this distribution, which
184       should be automatically installed by your CPAN client, there are a
185       number of optional features, used by additional plugins. You can
186       install any of these features by installing this distribution
187       interactively (e.g. "cpanm --interactive Devel::REPL").
188
189       ·   Completion plugin - extensible tab completion
190
191       ·   DDS plugin - better format results with Data::Dump::Streamer
192
193       ·   DDC plugin - even better format results with Data::Dumper::Concise
194
195       ·   INC completion driver - tab complete module names in use and
196           require
197
198       ·   Interrupt plugin - traps SIGINT to kill long-running lines
199
200       ·   Keywords completion driver - tab complete Perl keywords and
201           operators
202
203       ·   LexEnv plugin - variables declared with "my" persist between
204           statements
205
206       ·   MultiLine::PPI plugin - continue reading lines until all blocks are
207           closed
208
209       ·   Nopaste plugin - upload a session\'s input and output to a Pastebin
210
211       ·   PPI plugin - PPI dumping of Perl code
212
213       ·   Refresh plugin - automatically reload libraries with
214           Module::Refresh
215

SEE ALSO

217       ·   A comparison of various REPLs <http://shadow.cat/blog/matt-s-
218           trout/mstpan-17/>
219

SUPPORT

221       Bugs may be submitted through the RT bug tracker
222       <https://rt.cpan.org/Public/Dist/Display.html?Name=Devel-REPL> (or
223       bug-Devel-REPL@rt.cpan.org <mailto:bug-Devel-REPL@rt.cpan.org>).
224
225       There is also an irc channel available for users of this distribution,
226       at "#devel" on "irc.perl.org" <irc://irc.perl.org/#devel-repl>.
227

AUTHOR

229       Matt S Trout - mst (at) shadowcatsystems.co.uk
230       (<http://www.shadowcatsystems.co.uk/>)
231

CONTRIBUTORS

233       ·   Karen Etheridge <ether@cpan.org>
234
235       ·   Shawn M Moore <code@sartak.org>
236
237       ·   Chris Marshall <devel.chm.01@gmail.com>
238
239       ·   Matt S Trout <mst@shadowcat.co.uk>
240
241       ·   Oliver Gorwits <oliver@cpan.org>
242
243       ·   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
244
245       ·   Arthur Axel 'fREW' Schmidt <frioux@gmail.com>
246
247       ·   Andrew Moore <amoore@cpan.org>
248
249       ·   Alexis Sukrieh <sukria+perl@sukria.net>
250
251       ·   Tomas Doran (t0m) <bobtfish@bobtfish.net>
252
253       ·   epitaph <unknown>
254
255       ·   Norbert Buchmuller <norbi@nix.hu>
256
257       ·   Jesse Luehrs <doy@tozt.net>
258
259       ·   Dave Houston <dhouston@cpan.org>
260
261       ·   Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
262
263       ·   Zakariyya Mughal <zaki.mughal@gmail.com>
264
265       ·   Ryan Niebur <ryan@debian.org>
266
267       ·   Justin Hunter <justin.d.hunter@gmail.com>
268
269       ·   Ash Berlin <ash_github@firemirror.com>
270
271       ·   naquad <naquad@bd8105ee-0ff8-0310-8827-fb3f25b6796d>
272
273       ·   Stevan Little <stevan.little@iinteractive.com>
274
276       This software is copyright (c) 2007 by Matt S Trout - mst (at)
277       shadowcatsystems.co.uk (<http://www.shadowcatsystems.co.uk/>).
278
279       This is free software; you can redistribute it and/or modify it under
280       the same terms as the Perl 5 programming language system itself.
281
282
283
284perl v5.30.1                      2020-01-29                    Devel::REPL(3)
Impressum