Created
October 4, 2009 07:51
-
-
Save zoul/201241 to your computer and use it in GitHub Desktop.
How to write a simple REPL interface to a Perl module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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