This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix warnings (used once) for O.pm
authorTodd Rinaldo <toddr@cpan.org>
Wed, 13 Sep 2017 19:35:35 +0000 (14:35 -0500)
committerTodd Rinaldo <toddr@cpanel.net>
Wed, 8 Nov 2017 22:36:16 +0000 (16:36 -0600)
ext/B/O.pm

index 7393441..09a905e 100644 (file)
@@ -4,12 +4,15 @@ our $VERSION = '1.02';
 
 use B ();
 
+our $BEGIN_output;
+our $saveout_fh;
+
 sub import {
     my ($class, @options) = @_;
     my ($quiet, $veryquiet) = (0, 0);
     if ($options[0] eq '-q' || $options[0] eq '-qq') {
        $quiet = 1;
-       open (SAVEOUT, ">&STDOUT");
+       open ($saveout_fh, ">&", STDOUT);
        close STDOUT;
        open (STDOUT, ">", \$O::BEGIN_output);
        if ($options[0] eq '-qq') {
@@ -27,8 +30,8 @@ sub import {
        CHECK {
            if ($quiet) {
                close STDOUT;
-               open (STDOUT, ">&SAVEOUT");
-               close SAVEOUT;
+               open (STDOUT, ">&", $saveout_fh);
+               close $saveout_fh;
            }
 
            # Note: if you change the code after this 'use', please