What is your requirement?
If
a) you only need to change this file programatically
and
b) you only need to store scalars per value
then consider a tied hash. (See 'perltie' for info & examples).
Example: (untested, yadda yadda)
use Fcntl;
use SDBM_File;
tie (%ini, 'SDBM_File', $ini_db_file, O_RDWR, 0640)
or die( "Tie-dye :-) : $!" );
my $last_time = $ini{last_run_time};
if( $last_time ) {
print "Last run was [$ini{last_run_time}] seconds after the epoch\n"
+;
}
else {
print "Never been run before...\n";
}
$ini{last_run_time} = time();
untie %ini;
Basically it gives you a persistent hash over different runs of your script.
If you want to store data other than scalars you'll need to 'flatten' them somehow. Often this can be a join & split exercise, but they are other ways (and a module called Data::Dumper) to do this. |