The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Package::Checkpoint::Guard - Checkpoint the scalar, array and hash values in a package for automatic restoration

VERSION

version 0.01

SYNOPSIS

package Foo::Bar {
  our $foo = 1;
  our @bar = (1,2,3);
  our %baz = ( a => 1 );
}

{
  my $guard = Package::Checkpoint::Guard->new('Foo::Bar');

  # modify Foo::Bar
  $Foo::Bar::foo++;
  push @Foo::Bar::bar, 4;
  $Foo::Bar::baz{b} = 2;
}
# $guard falls out of scope...
# [$@%]Foo::Bar::{foo,bar,baz} are now back to their original values

DESCRIPTION

This class works exactly like Package::Checkpoint, except that it will automatically restore when it falls out of scope.

BASE CLASS

Package::Checkpoint

CAVEATS

Doesn't checkpoint or even consider a whole host of values that might be of interest, like subroutines or file handles.

SEE ALSO

Package::Stash

AUTHOR

Graham Ollis <plicease@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2021 by Graham Ollis.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.