SPDX-FileCopyrightText: 2013 Nicholas Clark <nick@ccl4.org>

SPDX-License-Identifier: Artistic-1.0

Again, we need this for 5.22.

From b86e5545be9b2e891e3ee8e2fba38b799b1836fc Mon Sep 17 00:00:00 2001
From: Nicholas Clark <nick@ccl4.org>
Date: Sun, 7 Jul 2013 15:12:42 +0200
Subject: [PATCH] Refactor ExtUtils::Embed to work with miniperl.

Remove the use of FileHandle, which relies on IO, and XS module.
Only load Getopt::Std if it is needed (in xsinit()), to avoid needing to add
Getopt::Std to lib/buildcustomize.pl
Require File::Spec instead of using it, as it exports nothing, so there is no
benefit to using it (but it costs a BEGIN block).
---
 lib/ExtUtils/Embed.pm | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git perl-5.18.4/lib/ExtUtils/Embed.pm perl-5.18.4/lib/ExtUtils/Embed.pm
index 9710630e51..758e24139c 100644
--- perl-5.18.4/lib/ExtUtils/Embed.pm
+++ perl-5.18.4/lib/ExtUtils/Embed.pm
@@ -2,10 +2,8 @@ require 5.002;
 
 package ExtUtils::Embed;
 require Exporter;
-require FileHandle;
 use Config;
-use Getopt::Std;
-use File::Spec;
+require File::Spec;
 
 #Only when we need them
 #require ExtUtils::MakeMaker;
@@ -18,7 +16,7 @@ use vars qw(@ISA @EXPORT $VERSION
 use strict;
 
 # This is not a dual-life module, so no need for development version numbers
-$VERSION = '1.30';
+$VERSION = '1.31';
 
 @ISA = qw(Exporter);
 @EXPORT = qw(&xsinit &ldopts 
@@ -54,7 +52,8 @@ sub xsinit {
        @mods = @$mods if $mods;
     }
     else {
-       getopts('o:s:');
+       require Getopt::Std;
+       Getopt::Std::getopts('o:s:');
        $file = $opt_o if defined $opt_o;
        $std  = $opt_s  if defined $opt_s;
        @mods = @ARGV;
@@ -65,7 +64,8 @@ sub xsinit {
 	$fh = \*STDOUT;
     }
     else {
-	$fh = new FileHandle "> $file";
+        open $fh, '>', $file
+            or die "Can't open '$file': $!";
     }
 
     push(@mods, static_ext()) if defined $std;
-- 
2.49.1

