Lexical-Persistence

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

      "develop" : {
         "requires" : {
            "Pod::Coverage::TrustPod" : "0",
            "Test::Pod" : "1.41",
            "Test::Pod::Coverage" : "1.08"
         }
      },
      "runtime" : {
         "requires" : {
            "Devel::LexAlias" : "0.05",
            "PadWalker" : "1.96",
            "strict" : "0",
            "warnings" : "0"
         }
      },
      "test" : {
         "requires" : {
            "Carp" : "1.26",
            "Scalar::Util" : "1.29",
            "Test::More" : "0.98",
            "constant" : "0",

META.yml  view on Meta::CPAN

  ExtUtils::MakeMaker: 6.30
dynamic_config: 0
generated_by: 'Dist::Zilla version 4.300035, CPAN::Meta::Converter version 2.132140'
license: perl
meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: 1.4
name: Lexical-Persistence
requires:
  Devel::LexAlias: 0.05
  PadWalker: 1.96
  strict: 0
  warnings: 0
resources:
  bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Lexical-Persistence
  homepage: http://search.cpan.org/dist/Lexical-Persistence/
  license: http://dev.perl.org/licenses/
  repository: git://github.com/rcaputo/lexical-persistence.git
version: 1.023

Makefile.PL  view on Meta::CPAN

  "BUILD_REQUIRES" => {},
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => "6.30"
  },
  "DISTNAME" => "Lexical-Persistence",
  "EXE_FILES" => [],
  "LICENSE" => "perl",
  "NAME" => "Lexical::Persistence",
  "PREREQ_PM" => {
    "Devel::LexAlias" => "0.05",
    "PadWalker" => "1.96",
    "strict" => 0,
    "warnings" => 0
  },
  "TEST_REQUIRES" => {
    "Carp" => "1.26",
    "Scalar::Util" => "1.29",
    "Test::More" => "0.98",
    "constant" => 0
  },
  "VERSION" => "1.023",

README  view on Meta::CPAN

    to avoid recompiling code every iteration. Lexical declarations are
    preserved between do() and compile() as well:

            use Lexical::Persistence;

            my $lp = Lexical::Persistence->new();
            $lp->do('my $count = 0');
            my $coderef = $lp->compile('print ++$count, "\\n"');
            $lp->call($coderef) for 1..10;

    do() inherits some limitations from PadWalker's peek_sub(). For
    instance, it cannot alias lexicals within sub() definitions in the
    supplied CODE string. However, Lexical::Persistence can do this with
    careful use of eval() and some custom CODE preparation.

  parse_variable VARIABLE_NAME
    This method determines whether VARIABLE_NAME should be persistent. If it
    should, parse_variable() will return three values: the variable's sigil
    ('$', '@' or '%'), the context name in which the variable persists (see
    set_context()), and the name of the member within that context where the
    value is stored. parse_variable() returns nothing if VARIABLE_NAME

README  view on Meta::CPAN


  pop_arg_context OLD_ARG_CONTEXT
    Restores OLD_ARG_CONTEXT after a target function has returned. The
    OLD_ARG_CONTEXT is the return value from the push_arg_context() call
    just prior to the target function's call.

    This method implements a default behavior. It's intended to be
    overridden or extended by subclasses.

SEE ALSO
    POE::Stage, Devel::LexAlias, PadWalker, Catalyst::Controller::BindLex.

  BUG TRACKER
    https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=Lexical-Persis
    tence

  REPOSITORY
    http://github.com/rcaputo/lexical-persistence
    http://gitorious.org/lexical-persistence

  OTHER RESOURCES

README.mkdn  view on Meta::CPAN

to avoid recompiling code every iteration.  Lexical declarations are
preserved between do() and compile() as well:

	use Lexical::Persistence;

	my $lp = Lexical::Persistence->new();
	$lp->do('my $count = 0');
	my $coderef = $lp->compile('print ++$count, "\\n"');
	$lp->call($coderef) for 1..10;

do() inherits some limitations from PadWalker's peek\_sub().  For
instance, it cannot alias lexicals within sub() definitions in the
supplied CODE string.  However, Lexical::Persistence can do this with
careful use of eval() and some custom CODE preparation.

## parse\_variable VARIABLE\_NAME

This method determines whether VARIABLE\_NAME should be persistent.  If
it should, parse\_variable() will return three values: the variable's
sigil ('$', '@' or '%'), the context name in which the variable
persists (see set\_context()), and the name of the member within that

README.mkdn  view on Meta::CPAN


Restores OLD\_ARG\_CONTEXT after a target function has returned.  The
OLD\_ARG\_CONTEXT is the return value from the push\_arg\_context() call
just prior to the target function's call.

This method implements a default behavior.  It's intended to be
overridden or extended by subclasses.

# SEE ALSO

[POE::Stage](http://search.cpan.org/perldoc?POE::Stage), [Devel::LexAlias](http://search.cpan.org/perldoc?Devel::LexAlias), [PadWalker](http://search.cpan.org/perldoc?PadWalker),
[Catalyst::Controller::BindLex](http://search.cpan.org/perldoc?Catalyst::Controller::BindLex).

## BUG TRACKER

https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=Lexical-Persistence

## REPOSITORY

http://github.com/rcaputo/lexical-persistence
http://gitorious.org/lexical-persistence

lib/Lexical/Persistence.pm  view on Meta::CPAN

=cut

package Lexical::Persistence;

use warnings;
use strict;

our $VERSION = '1.020';

use Devel::LexAlias qw(lexalias);
use PadWalker qw(peek_sub);

=head2 new

Create a new lexical persistence object.  This object will store one
or more persistent contexts.  When called by this object, lexical
variables will take on the values kept in this object.

=cut

sub new {

lib/Lexical/Persistence.pm  view on Meta::CPAN

to avoid recompiling code every iteration.  Lexical declarations are
preserved between do() and compile() as well:

	use Lexical::Persistence;

	my $lp = Lexical::Persistence->new();
	$lp->do('my $count = 0');
	my $coderef = $lp->compile('print ++$count, "\\n"');
	$lp->call($coderef) for 1..10;

do() inherits some limitations from PadWalker's peek_sub().  For
instance, it cannot alias lexicals within sub() definitions in the
supplied CODE string.  However, Lexical::Persistence can do this with
careful use of eval() and some custom CODE preparation.

=cut

sub do {
	my ($self, $code) = @_;

	my $sub = $self->compile( $code ) or die $@;

lib/Lexical/Persistence.pm  view on Meta::CPAN


=cut

sub pop_arg_context {
	my ($self, $old_context) = @_;
	$self->set_context( arg => $old_context );
}

=head1 SEE ALSO

L<POE::Stage>, L<Devel::LexAlias>, L<PadWalker>,
L<Catalyst::Controller::BindLex>.

=head2 BUG TRACKER

https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=Lexical-Persistence

=head2 REPOSITORY

http://github.com/rcaputo/lexical-persistence
http://gitorious.org/lexical-persistence



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