on Wed, 21 Aug 2002 11:33:06 GMT, [EMAIL PROTECTED] wrote: > 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.
> open (FILE, ">>config.ini") || die "Can't open config.ini"; > > while ($line = <FILE>) { You are trying to read from a file you opened for appending. Try this instead: #! perl -wi.bak use strict; my ($d, $m, $y) = (localtime())[3..5]; my $date = sprintf("%4d%02d%02d", $y+1900, $m+1, $d); while (<>) { s/\d{8}/$date/g; print; } and run it as: $ tryme config.ini This will edit config.ini in-place (sort-of) and create a backup copy config.ini.bak before making the changes. (BTW, you *are* sure there are no other 8-digit numbers in you file, aren't you ;-) -- felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]