On Wed, 21 Aug 2002 [EMAIL PROTECTED] wrote: > Hi, > > I'm trying to substitute all references to a date (of the format > YYYYMMDD) in a file to the current date. I'm obviously doing something > wrong here ('cause it doesn't work!:}), as no change is made to the > config.ini file. > the $date variable is derived form another part of my script. > > thanks, > Adrian > > open (FILE, ">>config.ini") || die "Can't open config.ini";
As has already been pointed out you are opening the file in append mode and trying to read from it. If you want to modify this file you will have to create a temp file, write into it and copy it back. If your @ARGV contains nothing you can do this $^I = '~' # perldoc perlvar push (@ARGV, 'config.ini'); while (<>) { s/\d{8}/$date/g; print; } > > while ($line = <FILE>) { When FILE is opened in write mode '>' (with warnings turned on) this gives this message 'Filehandle TEST opened only for output at...'. The same message does not appear when it is opened in append mode '>>'. Any particular reason for this perl versions - 5.8.0 and 5.6.1 OS : RH linux 7.3 > chomp($line); > $line=~s/\d{8}/$date/g; > } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]