Re: in-place edit in TestRun.pm
Randy Kobes wrote: On Thu, 11 Mar 2004, Stas Bekman wrote: Randy Kobes wrote: 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: BTW, how did you notice this problem? Did you try to relocate a project to a new directory? Or did it just hit in on the normal run? If the latter, then something is broken. It was a bit strange I got a fresh checkout, then built and ran the tests, which timed out, for the reasons of thread limits we were discussing. So I edited httpd.conf, and when running perl t/TEST the in-place edit problem arose. After applying that patch, the editing was run, successfully. So, it is broken. Can you trace why does it get there? It's supposed to get to this rewrite-the-file part only if you have configured the test suite in directory /foo and then moved it to /bar and trying to run the test suite again. Untill now things were totally broken and you will have to go and manually cleanup the autogenerated files in t/conf. This change is supposed to gracefully recover. But I guess there are rough edges. __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
Re: in-place edit in TestRun.pm
On Wed, 10 Mar 2004, Stas Bekman wrote: > Randy Kobes wrote: > > Hi, > >A recent change in Apache-Test/lib/Apache/TestRun.pm > > involves an in-place edit, at around line 765: [ .. ] > > Unfortunately, Win32 can't do such in-place edits: [ ... ] > why not doing: > > local $^I = ".bak"; # windows can't do inplace edit > local @ARGV = $config_file; > while( <> ) { > s/old/new/; > print; > } > unlink "$config_file.bak"; > > much simpler. Very true ... I'll make that change - thanks! -- best regards, randy
Re: in-place edit in TestRun.pm
Randy Kobes wrote: 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. sigh :( shouldn't the perlrun and perlvar manpages state that bug? 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? Sure, will you do it? But you can't use 'open my $fh', must use Symbol::gensym to support perl < 5.6. Also please drop () for consistency. Thanks. But if you say that this works: perl -spi.bak why not doing: local $^I = ".bak"; # windows can't do inplace edit local @ARGV = $config_file; while( <> ) { s/old/new/; print; } unlink "$config_file.bak"; much simpler. __ Stas BekmanJAm_pH --> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com
in-place edit in TestRun.pm
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