From: Sébastien Aperghis-Tramoni Date: Sun, 30 Oct 2005 23:52:41 +0000 (+0100) Subject: Making ExtUtils::Constant compatible with Perl 5.004 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=67a202d94d4ec1df620a7231c2016d22a84605c5;p=p5sagit%2Fp5-mst-13.2.git Making ExtUtils::Constant compatible with Perl 5.004 Message-ID: <1130712761.43654eb9cd9f7@imp4-g19.free.fr> with tweaks by chromatic and me. p4raw-id: //depot/perl@25927 --- diff --git a/lib/ExtUtils/Constant.pm b/lib/ExtUtils/Constant.pm index 00f5b42..9e2b6b8 100644 --- a/lib/ExtUtils/Constant.pm +++ b/lib/ExtUtils/Constant.pm @@ -1,6 +1,6 @@ package ExtUtils::Constant; use vars qw (@ISA $VERSION @EXPORT_OK %EXPORT_TAGS); -$VERSION = 0.16; +$VERSION = 0.17; =head1 NAME @@ -474,8 +474,18 @@ sub WriteConstants { croak "Module name not specified" unless length $ARGS{NAME}; - open my $c_fh, ">$ARGS{C_FILE}" or die "Can't open $ARGS{C_FILE}: $!"; - open my $xs_fh, ">$ARGS{XS_FILE}" or die "Can't open $ARGS{XS_FILE}: $!"; + my ($c_fh, $xs_fh); + if ($] <= 5.008) { + # We need these little games, rather than doing things unconditionally, + # because we're used in core Makefile.PLs before IO is available (needed + # by filehandle), but also we want to work on older perls where undefined + # scalars do not automatically turn into anonymous file handles. + require FileHandle; + $c_fh = FileHandle->new(); + $xs_fh = FileHandle->new(); + } + open $c_fh, ">$ARGS{C_FILE}" or die "Can't open $ARGS{C_FILE}: $!"; + open $xs_fh, ">$ARGS{XS_FILE}" or die "Can't open $ARGS{XS_FILE}: $!"; # As this subroutine is intended to make code that isn't edited, there's no # need for the user to specify any types that aren't found in the list of