httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Randy Kobes <ra...@theoryx5.uwinnipeg.ca>
Subject in-place edit in TestRun.pm
Date Thu, 11 Mar 2004 05:26:02 GMT
Hi,
   A recent change in Apache-Test/lib/Apache/TestRun.pm
involves an in-place edit, at around line 765:
    local @ARGV = $config_file;
    while( <> ) {
        s/old/new/;
        print;
    }
Unfortunately, Win32 can't do such in-place edits:
for example,
   perl -spi -e 's#old#new#' file.txt
won't work, but
   perl -spi.bak -e 's#old#new#' file.txt
will. Would something like
   my $orig = $config_file . '.orig';
   rename $config_file, $orig or die "...";
   open(my $rfh, $orig) or die "...";
   open(my $wfh, '>', $file) or die "...";
   while(<$rfh>) {
       s{old}{new}g;
       print $wfh $_;
   }
   close $rfh;
   close $wfh;
   unlink $orig;
be OK?

-- 
best regards,
randy

Mime
View raw message