1 # First cut at handling packages.
3 # doesn't work very well, and totally doesn't work with the wrap_as_sub
4 # stuff ;) For comments only really
6 package Devel::REPL::Plugin::Packages;
10 has 'current_package' => (
17 around 'eval' => sub {
18 # we don't call forward to $orig here, since the new sub-wrapped system
19 # doesn't work. We spot package declarations and retain the name so
20 # that we can reenter the package for each statement. Not sure the
21 # regex is bob on, but then it doesn't work anyway...
25 my @ret=("OOPS: ".__PACKAGE__.'$ret unset!');
27 # $self->print("Line is: $line");
28 if($line=~/\s*package\s([\w:]*)/) {
29 # $self->print("Recognised as a package switch");
30 # $ret=$self->$orig($line);
32 # $self->print("ret: @ret");
33 # should check for good return here
34 $self->current_package($1);
35 # $self->print('curr pkg: '.$self->current_package);
37 # $self->print("Not a package switch");
38 my $packaged_line='package ' . $self->current_package . '; '.$line;
39 # $self->print("packaged line: $packaged_line");
40 # @ret=$self->$orig($packaged_line);
41 @ret=eval $packaged_line;
42 # $self->print("ret: @ret");