==================================

What I am trying to do is to read the "download.properites" file first
and then change the value for "currentDate" and then store it back to
property file. Most of this works. But while writing it back to the
property file it appends all the properties at the end. This way
property file size goes on increasing on each run.

Is there way I can do in-place replacement and avoid the duplication?

Yo have to reopen the properties file:

  use Config::Properties;
  open PROPS, "<", "download.properties" or die $!;
  $properties = new Config::Properties();
  $properties->load(*PROPS);
  close PROPS;

  $currentDate = $properties->getProperty("currentDate");
  $currentDate = "Changed";
  $properties->changeProperty("currentDate", $currentDate);

  open PROPS, ">", "download.properties" or die $!;
  $properties->save(*PROPS);
  close PROPS;

Or alternatively, use seek and truncate.

- Salva

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to