in reply to read-write troubles
open FILE, "+<$filename" or die "I checked a return call: $!\n"; { local $/; # Always localize this so it doesn't interfere with othe +r parts of the program. $old_data = <FILE>; } #do some stuff seek FILE, 0, 0 or die "Can't seek on $filename: $!\n"; print FILE $new_data or die "Can't print to $filename: $!\n"; truncate FILE, tell(FILE) or die "Can't truncate $filename: $!\n"; close FILE or die "Can't close $filename: $!\n";
Cheers,
Ovid
Join the Perlmonks Setiathome Group or just go the the link and check out our stats.
|
|---|