@@ -178,13 +178,9 @@ is( $?, 0, ' exited normally' ) ||
178178 diag $test_out ;
179179
180180# now simulate what Module::Install does, and edit $(PERL) to add flags
181- open my $fh , ' <' , $makefile ;
182- my $mtext = join ' ' , <$fh >;
183- close $fh ;
181+ my $mtext = slurp($makefile );
184182$mtext =~ s / ^(\s *PERL\s *=.*)$/ $1 -Iinc/ m ;
185- open $fh , ' >' , $makefile ;
186- print $fh $mtext ;
187- close $fh ;
183+ write_file($makefile , $mtext );
188184
189185sub check_dummy_inst {
190186 my ($loc , $install_args , $label , $skipsubdir ) = @_ ;
@@ -424,10 +420,10 @@ note "META file validity"; SKIP: {
424420
425421# Make sure init_dirscan doesn't go into the distdir
426422# also with a "messup.PL" that will make a build fail
427- open $fh , ' > ' , ' messup.PL' or die " messup.PL: $! " ;
428- print $fh ' print "Extracting messup (with variable substitutions)\n"; ' . " \n " ;
429- print $fh ' die' ;
430- close $fh ;
423+ write_file( ' messup.PL' , <<'TEXT' ) ;
424+ print "Extracting messup (with variable substitutions)\n";
425+ die;
426+ TEXT
431427@mpl_out = run(qq{ $perl Makefile.PL "PREFIX=$DUMMYINST "} );
432428
433429cmp_ok( $? , ' ==' , 0, ' Makefile.PL exited with zero' ) || diag(@mpl_out );
@@ -457,13 +453,10 @@ open(STDERR, ">&SAVERR") or die $!;
457453close SAVERR;
458454
459455# test linkext=>{LINKTYPE=>''} still installs a pure-perl installation
460- # warning, edits the Makefile.PL so either rewrite after this or do this last
461456my $file = ' Makefile.PL' ;
462- my $text = slurp $file ;
457+ my $text = my $preserve_MPL = slurp $file ;
463458ok(($text =~ s #\) ;# linkext=>{LINKTYPE=>''},\n $& # ), ' successful M.PL edit' );
464- open $fh , ' >' , $file or die " $file : $! " ;
465- print $fh $text ;
466- close $fh ;
459+ write_file($file , $text );
467460# now do with "Liar" subdir still there
468461rmtree $DUMMYINST ; # so no false positive from before
469462@mpl_out = run(qq{ $perl Makefile.PL "PREFIX=$DUMMYINST "} );
@@ -474,6 +467,10 @@ rmtree 'Liar';
474467rmtree $DUMMYINST ; # so no false positive from before
475468@mpl_out = run(qq{ $perl Makefile.PL "PREFIX=$DUMMYINST "} );
476469check_dummy_inst($DUMMYINST , ' ' , " with PREFIX=$DUMMYINST minus subdir" , 1);
470+ write_file($file , $preserve_MPL ); # restore Makefile.PL
471+ $realclean_out = run(" $make realclean" );
472+ rmtree ' Liar' ;
473+ rmtree $DUMMYINST ;
477474
478475sub _normalize {
479476 my $hash = shift ;
0 commit comments