This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldelta entry for ce3778a3796be3e4604ed9b3671ea624c5affe0b.
[perl5.git] / regen / regen_lib.pl
index b64e0b0..abeecba 100644 (file)
@@ -67,7 +67,7 @@ sub close_and_rename {
     close $fh or die "Error closing $name: $!";
 
     if ($TAP) {
-        # Don't use compare beacuse if there are errors it doesn't give any
+        # Don't use compare because if there are errors it doesn't give any
         # way to generate diagnostics about what went wrong.
         # These files are small enough to read into memory.
         local $/;
@@ -224,4 +224,24 @@ sub wrap {
     Text::Wrap::wrap(@_);
 }
 
+# return the perl version as defined in patchlevel.h.
+# (we may be being run by another perl, so $] won't be right)
+# return e.g. (5, 14, 3, "5.014003")
+
+sub perl_version {
+    my $plh = 'patchlevel.h';
+    open my $fh, "<", $plh or die "can't open '$plh': $!\n";
+    my ($v1,$v2,$v3);
+    while (<$fh>) {
+        $v1 = $1 if /PERL_REVISION\s+(\d+)/;
+        $v2 = $1 if /PERL_VERSION\s+(\d+)/;
+        $v3 = $1 if /PERL_SUBVERSION\s+(\d+)/;
+    }
+    die "can't locate PERL_REVISION in '$plh'"   unless defined $v1;
+    die "can't locate PERL_VERSION in '$plh'"    unless defined $v2;
+    die "can't locate PERL_SUBVERSION in '$plh'" unless defined $v3;
+    return ($v1,$v2,$v3, sprintf("%d.%03d%03d", $v1, $v2, $v3));
+}
+
+
 1;