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

NAME

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

SYNOPSIS

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

DESCRIPTION

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

USAGE

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

REQUIREMENTS

162       In addition to the contents of the standard Perl distribution, you will
163       need the following:
164
165       ·   Moose >= 0.74
166
167       ·   MooseX::Object::Pluggable >= 0.0009
168
169       ·   MooseX::Getopt >= 0.18
170
171       ·   MooseX::AttributeHelpers >= 0.16
172
173       ·   namespace::clean
174
175       ·   File::HomeDir
176
177       ·   Task::Weaken
178
179       ·   B::Concise
180
181       ·   Term::ANSIColor
182
183       ·   Devel::Peek
184
185       Optionally, some plugins if installed will require the following
186       modules:
187
188       ·   PPI
189
190       ·   Data::Dump::Streamer
191
192       ·   Data::Dumper::Concise
193
194       ·   File::Next
195
196       ·   Sys::SigAction
197
198       ·   B::Keywords
199
200       ·   Lexical::Persistence
201
202       ·   App::Nopaste
203
204       ·   Module::Refresh
205

AUTHOR

207       Matt S Trout - mst (at) shadowcatsystems.co.uk
208       (<http://www.shadowcatsystems.co.uk/>)
209

CONTRIBUTORS

211       Stevan Little - stevan (at) iinteractive.com
212       Alexis Sukrieh - sukria+perl (at) sukria.net
213       epitaph
214       mgrimes - mgrimes (at) cpan dot org
215       Shawn M Moore - sartak (at) gmail.com
216       Oliver Gorwits - oliver on irc.perl.org
217       Andrew Moore - "<amoore@cpan.org>"
218       Norbert Buchmuller "<norbi@nix.hu>"
219       Dave Houston "<dhouston@cpan.org>"
220       Chris Marshall
221

LICENSE

223       This library is free software under the same terms as perl itself
224
225
226
227perl v5.12.1                      2010-06-15                    Devel::REPL(3)
Impressum