From: Rafael Garcia-Suarez Date: Mon, 8 Mar 2010 15:11:43 +0000 (+0100) Subject: B::sub_generation is not available for perls < 5.8.9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=40a34d2a6241f2b5cf618cd77336a9a537c5ce2b;p=p5sagit%2Fp5-mst-13.2.git B::sub_generation is not available for perls < 5.8.9 --- diff --git a/dist/Safe/Safe.pm b/dist/Safe/Safe.pm index e33598e..cc87280 100644 --- a/dist/Safe/Safe.pm +++ b/dist/Safe/Safe.pm @@ -3,7 +3,6 @@ package Safe; use 5.003_11; use strict; use Scalar::Util qw(reftype); -use B qw(sub_generation); $Safe::VERSION = "2.25"; @@ -32,6 +31,18 @@ BEGIN { eval q{ use Carp::Heavy; } } +use B (); +BEGIN { + no strict 'refs'; + if (defined &B::sub_generation) { + *sub_generation = \&B::sub_generation; + } + else { + # fake sub generation changing for perls < 5.8.9 + my $sg; *sub_generation = sub { ++$sg }; + } +} + use Opcode 1.01, qw( opset opset_to_ops opmask_add empty_opset full_opset invert_opset verify_opset