Devel-REPL
view release on metacpan or search on metacpan
lib/Devel/REPL.pm view on Meta::CPAN
$_
In the first example above you see the output of the command (C<Hello,
world!>), if any, and then the return value of the statement (C<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 L</"SYNOPSIS"> above, you'll have the
L<History|Devel::REPL::Plugin::History> and L<LexEnv|Devel::REPL::Plugin::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.
C<!53>). The LexEnv plugin ensures that lexical variables declared with the
C<my> keyword will automatically persist between statements executed in the
REPL shell.
When you C<use> any Perl module, the C<import()> will work as expected - the
exported functions from that module are available for immediate use:
$_ carp "I'm dieeeing!\n"
String found where operator expected at (eval 129) line 5, near "carp "I'm dieeeing!\n""
(Do you need to predeclare carp?)
Compile error: syntax error at (eval 129) line 5, near "carp "I'm dieeeing!\n""
BEGIN not safe after errors--compilation aborted at (eval 129) line 5.
$_ use Carp
$_ carp "I'm dieeeing!\n"
I'm dieeeing!
at /usr/share/perl5/Lexical/Persistence.pm line 327
1
$_
To quit from the shell, hit C<Ctrl+D> or C<Ctrl+C>.
MSWin32 NOTE: control keys won't work if TERM=dumb
because readline functionality will be disabled.
=head2 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 C<re.pl> program looks for C<< $HOME/.re.pl/repl.rc >>, 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$ re.pl --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$ re.pl --rcfile /path/to/my/project/repl.rc
Within the run control file you might want to load plugins. This is covered in
L</"The REPL shell object"> section, below.
=head2 Profiles
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 L<Devel::REPL::Profile> manual page.
A C<Standard> profile ships with C<Devel::REPL>; it loads the following plugins
(note that some of these require optional features -- or you can also use the
C<Minimal> profile):
=over 4
=item *
L<Devel::REPL::Plugin::History>
=item *
L<Devel::REPL::Plugin::LexEnv>
=item *
L<Devel::REPL::Plugin::DDS>
=item *
L<Devel::REPL::Plugin::Packages>
=item *
L<Devel::REPL::Plugin::Commands>
=item *
L<Devel::REPL::Plugin::MultiLine::PPI>
=item *
L<Devel::REPL::Plugin::Colors>
=item *
L<Devel::REPL::Plugin::Completion>
=item *
L<Devel::REPL::Plugin::CompletionDriver::INC>
=item *
L<Devel::REPL::Plugin::CompletionDriver::LexEnv>
=item *
( run in 3.120 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )