First you can drop the Windows centric paths and use / instead of \ Perl will
supply Windows with the correct path delimiters for the platform automagically changing
/ into \ as required.
The path is not however your problem. As you open the file for read/write you need to remember that at
the end of the read you are at EOF so you need to seek the begining of the file
and also truncate it to 0 unless you want to run the risk of getting crap at the end. I have added
as die to the print CONFIG (remove the seek and truncate and you will get the error). This runs fine now. BTW don't
open STDERR ">error.log" without including some path info. Even ./ for the current working directory
makes it obvious where to look for this file. Also when you read data in from a file the newlines
will still be there so you don't need to add more in your substitution
open(CONFIG, "+<c:/blah.txt" ) or die "Can't open blah.txt: $!";
my @configfile = <CONFIG>;
seek CONFIG, 0, 0; # go to start of file for overwrite
truncate CONFIG, 0; # get rid of old file
foreach my $configfile (@configfile) {
$configfile =~ s/serverport 111$/serverport $port/;
print CONFIG $configfile or die $!;
}
close(CONFIG);
close(STDERR);
cheers
tachyon
s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print
|