App-REPL

 view release on metacpan or  search on metacpan

META.yml  view on Meta::CPAN

# http://module-build.sourceforge.net/META-spec.html
#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
name:         App-REPL
version:      0.012
version_from: lib/App/REPL.pm
installdirs:  site
requires:
    PadWalker:                     1.5
    PPI:                           1.118
    Term::ANSIColor:               0
    Test::More:                    0

distribution_type: module
generated_by: ExtUtils::MakeMaker version 6.30

Makefile.PL  view on Meta::CPAN

WriteMakefile(
    NAME                => 'App::REPL',
    AUTHOR              => 'Julian Fondren <ayrnieu@cpan.org>',
    ABSTRACT            => 'A read-eval-print-loop for Perl',
    VERSION_FROM        => 'lib/App/REPL.pm',
    ABSTRACT            => 'A read-eval-print-loop for Perl',
    EXE_FILES           => [ 'iperl' ],
    PREREQ_PM => {
        'Test::More'      => 0,
        'Term::ANSIColor' => 0,
        'PadWalker'       => 1.5,
        'PPI'             => 1.118,  # buggy, but we monkeypatch it
    },
    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
    clean               => { FILES => 'App-REPL-*' },
);

README  view on Meta::CPAN

  Well, several things.

  1. The current version monkey-patches a bug out of PPI, so that
     I don't have to wait for the next PPI to be released before
     I can get comments on this (alpha, anyway) version of App-REPL.

  2. It relies on the way PPI structures things, and -modifies-
     that structure without PPI's knowledge, in ways that I figured
     out through trial and Data::Dumper

  3. It uses PadWalker

7. Yow.  Anything else I should worry about?

  Everything you enter will be eval'd with lengthy prologue and
  epilogue code, first to set up the environment and finally to
  remember what you did to the environment.  Although this system
  -does- try to handle packages well, it currently only recognizes
  the final package of your eval.  So, if you do:

    package A; my $b = 1; package B;

iperl  view on Meta::CPAN

#! /usr/bin/env perl
use strict;
use warnings;
use Term::ANSIColor ':constants';
$Term::ANSIColor::AUTORESET = 1;

# ----------------------------------------------------------------------
# This first, to keep PadWalker away from lexical variables below.
sub scoped_eval {
  print MAGENTA @_ if $App::REPL::DEBUG;
  eval shift;
  print BOLD YELLOW $@ if $@;
}

use PadWalker 'peek_my';
use PPI;
use PPI::Find;
use Data::Dumper;
use Symbol;
use Term::ReadLine;
$App::REPL::DEBUG = 0;

{ my $in_package = 'App::REPL';
  sub in_package { @_ ? $in_package = shift : $in_package }
}

iperl  view on Meta::CPAN

  for (keys %$h) {
    /^(.)/;
    $r .= "my $_ = $1" . q,{${", . in_package . q,::REPL::env"}->, . "{'$_'}};\n"
  }
  $r . PRO_IN
}
use constant EPI => <<'EOE';
  ;
  no strict 'refs';
  for (Symbol::qualify('')) { s/::$//; main::in_package($_) }
  ${main::in_package . '::REPL::env'} = PadWalker::peek_my(0)
EOE

# ----------------------------------------------------------------------
# More magic.  This finds the final statement of some Perl, wherever
# that statement may be (even if its result cannot escape the overall
# evaluation), and saves its value in $App::REPL::ret
#--
$App::REPL::ret = '';
{ my $f = PPI::Find->new(sub { shift->isa('PPI::Statement') });
  sub save_ret {

lib/App/REPL.pm  view on Meta::CPAN

package App::REPL;
use warnings;
use strict;
use Data::Dumper;
use PadWalker 'peek_my';
use Term::ANSIColor ':constants';
$Term::ANSIColor::AUTORESET = 1;
require Exporter;
use vars qw(@ISA @EXPORT $VERSION);

$VERSION = '0.012';
@ISA = qw(Exporter);
@EXPORT = qw(x p env ret rdebug help);

# ----------------------------------------------------------------------



( run in 0.858 second using v1.01-cache-2.11-cpan-05444aca049 )