From: David Mitchell Date: Sun, 16 Aug 2009 23:31:45 +0000 (+0100) Subject: [perl #68530] "version::CLASS" warning in Safe.pm X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a930c511fcc6cf6f5ef849a9a4a028ff1cd6e27a;p=p5sagit%2Fp5-mst-13.2.git [perl #68530] "version::CLASS" warning in Safe.pm If any of the std variables being aliased into the Safe::rootN package don't actually exist, and if they are not one of the special "don't warn" variables, then you can get an 'only used once' warning. So lets not. (Also bumps version number). --- diff --git a/ext/Safe/Safe.pm b/ext/Safe/Safe.pm index 9d3d589..b27c047 100644 --- a/ext/Safe/Safe.pm +++ b/ext/Safe/Safe.pm @@ -3,7 +3,7 @@ package Safe; use 5.003_11; use strict; -$Safe::VERSION = "2.17"; +$Safe::VERSION = "2.17_01"; # *** Don't declare any lexicals above this point *** # @@ -243,13 +243,15 @@ sub share_from { my ($var, $type); $type = $1 if ($var = $arg) =~ s/^(\W)//; # warn "share_from $pkg $type $var"; - *{$root."::$var"} = (!$type) ? \&{$pkg."::$var"} + for (1..2) { # assign twice to avoid any 'used once' warnings + *{$root."::$var"} = (!$type) ? \&{$pkg."::$var"} : ($type eq '&') ? \&{$pkg."::$var"} : ($type eq '$') ? \${$pkg."::$var"} : ($type eq '@') ? \@{$pkg."::$var"} : ($type eq '%') ? \%{$pkg."::$var"} : ($type eq '*') ? *{$pkg."::$var"} : croak(qq(Can't share "$type$var" of unknown type)); + } } $obj->share_record($pkg, $vars) unless $no_record or !$vars; }