X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fp5-CGI-Ex;a=blobdiff_plain;f=lib%2FCGI%2FEx%2FTemplate.pm;h=773000cb1a8cf7442d276d2f383bf6fd9a907245;hp=52d92a07054174edc0763cd70ce2c0ab247df88b;hb=83f0c6a9aaf9bc520cef93b958d51a5d85e8999c;hpb=48c4840be1f154e262de2c161cb86dc5000dfe47 diff --git a/lib/CGI/Ex/Template.pm b/lib/CGI/Ex/Template.pm index 52d92a0..773000c 100644 --- a/lib/CGI/Ex/Template.pm +++ b/lib/CGI/Ex/Template.pm @@ -39,7 +39,7 @@ use vars qw($VERSION ); BEGIN { - $VERSION = '2.05'; + $VERSION = '2.06'; $PACKAGE_EXCEPTION = 'CGI::Ex::Template::Exception'; $PACKAGE_ITERATOR = 'CGI::Ex::Template::Iterator'; @@ -280,6 +280,8 @@ BEGIN { $WHILE_MAX = 1000; $EXTRA_COMPILE_EXT = '.sto'; + + eval {require Scalar::Util}; }; ###----------------------------------------------------------------### @@ -1936,7 +1938,8 @@ sub play_MACRO { $sub_tree = $sub_tree->[0]->[4]; } - my $self_copy = $self->weak_copy; + my $self_copy = $self; + eval {require Scalar::Util; Scalar::Util::weaken($self_copy)}; ### install a closure in the stash that will handle the macro $self->set_variable($name, sub { @@ -2778,20 +2781,6 @@ sub list_plugins { }; } -### get a copy of self without circular refs for use in closures -sub weak_copy { - my $self = shift; - my $self_copy; - if (eval { require Scalar::Util } - && defined &Scalar::Util::weaken) { - $self_copy = $self; - Scalar::Util::weaken($self_copy); - } else { - $self_copy = bless {%$self}, ref($self); # hackish way to avoid circular refs on old perls (pre 5.8) - } - return $self_copy; -} - sub debug_node { my ($self, $node) = @_; my $info = $self->node_info($node);