Skip to content

Instantly share code, notes, and snippets.

@zoul
Created October 4, 2009 07:51
Show Gist options
  • Save zoul/201241 to your computer and use it in GitHub Desktop.
Save zoul/201241 to your computer and use it in GitHub Desktop.
How to write a simple REPL interface to a Perl module
package REPL;
use Modern::Perl;
use Moose;
sub foo
{
return "foo";
}
sub run
{
use Devel::REPL;
my $repl = new Devel::REPL;
$repl->load_plugin($_) for qw/History LexEnv Refresh/;
$repl->run;
}
run if not caller;
1;
__DATA__
$ perl REPL.pm
$ REPL->new->foo;
bar
$ perl -MREPL -E "say REPL->new->foo"
bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment