This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
bigint: Fix new oct override for older Math::BigInt
[perl5.git] / dist / bignum / lib / bigint.pm
index 3120fdd..467a67d 100644 (file)
@@ -1,7 +1,7 @@
 package bigint;
 use 5.006;
 
 package bigint;
 use 5.006;
 
-$VERSION = '0.30';
+$VERSION = '0.31';
 use Exporter;
 @ISA           = qw( Exporter );
 @EXPORT_OK     = qw( PI e bpi bexp hex oct );
 use Exporter;
 @ISA           = qw( Exporter );
 @EXPORT_OK     = qw( PI e bpi bexp hex oct );
@@ -137,7 +137,7 @@ sub oct(' . $proto . ')' . <<'.';
   {
   my $i = @_ ? $_[0] : $_;
   # oct() should never fall back to decimal
   {
   my $i = @_ ? $_[0] : $_;
   # oct() should never fall back to decimal
-  return Math::BigInt->from_oct($i) if $i =~ /^(?:0[0-9]|[1-9])/;
+  return Math::BigInt->from_oct($i) if $i =~ s/^(?=0[0-9]|[1-9])/0/;
   Math::BigInt->new($i);
   }
 .
   Math::BigInt->new($i);
   }
 .
@@ -166,7 +166,7 @@ sub _oct(_)
     unless $$hh{bigint}||$$hh{bignum}||$$hh{bigrat};
   my $i = $_[0];
   # oct() should never fall back to decimal
     unless $$hh{bigint}||$$hh{bignum}||$$hh{bigrat};
   my $i = $_[0];
   # oct() should never fall back to decimal
-  return Math::BigInt->from_oct($i) if $i =~ /^(?:0[0-9]|[1-9])/;
+  return Math::BigInt->from_oct($i) if $i =~ s/^(?=0[0-9]|[1-9])/0/;
   Math::BigInt->new($i);
   }
 .
   Math::BigInt->new($i);
   }
 .