Skip to content
Browse files

Remove Guard.pm dependency

  • Loading branch information...
1 parent 6e65e10 commit e3ad94dcac0ab854c5cf852d312b909ed17c00eb @gfx gfx committed Nov 2, 2010
Showing with 9 additions and 16 deletions.
  1. +0 −3 Makefile.PL
  2. +9 −13 lib/Scope/Container.pm
View
3 Makefile.PL
@@ -2,9 +2,6 @@ use inc::Module::Install;
name 'Scope-Container';
all_from 'lib/Scope/Container.pm';
-# requires '';
-requires 'Log::Minimal';
-requires 'Guard';
tests 't/*.t';
author_tests 'xt';
View
22 lib/Scope/Container.pm
@@ -2,7 +2,6 @@ package Scope::Container;
use strict;
use warnings;
-use Guard;
use Carp qw//;
use base qw/Exporter/;
@@ -15,25 +14,22 @@ my $C=0;
sub start_scope_container {
my %args = @_;
my $old;
- if ( $args{-clear} ) {
- undef $CONTEXT;
- $CONTEXT = {};
- }
- elsif ( defined $CONTEXT ) {
+ if ( defined $CONTEXT and !$args{-clear} ) {
$old = $CONTEXT;
$CONTEXT = { map { $_ => $old->{$_} } keys %$old };
}
else {
$CONTEXT = {};
}
- my $c = $C++;
- return guard {
- --$C;
- Carp::carp("nested scope_container found") if $c != $C;
- undef $CONTEXT;
- $CONTEXT = $old if defined $old;
- };
+ return bless { c => $C++, old => $old }, __PACKAGE__;
+}
+
+sub DESTROY {
+ my($self) = @_;
+ Carp::carp("nested scope_container found") if $self->{c} != --$C;
+ $CONTEXT = $self->{old};
+ return;
}
sub scope_container {

0 comments on commit e3ad94d

Please sign in to comment.
Something went wrong with that request. Please try again.