Neither script produces error messages. I added some debugging statements inside prefs.pm so I could see the execution flow (and fixed the newval statement):
pref.pm
package prefs;
use strict;
use Config::IniFiles;
our @ISA = qw( Config::IniFiles );
sub new {
my $self = shift;
my $class = (ref $self) || $self;
print "creating $class\n";
my $fname = 'fubar.ini';
my $obj;
if (-f $fname) {
$obj = $self->SUPER::new( -file => $fname );
} else {
$obj = $self->SUPER::new();
$obj->SetFileName( $fname );
$obj->newval('fubar', 'var1', 'default');
}
return bless($obj, $class);
}
sub DESTROY {
my $self = shift;
$self->RewriteConfig();
print "destroying $self\n";
$self->SUPER::DESTROY(@_);
}
1;
Here is the output:
I am using Perl 5.8.6 on Win32 (Windows XP) with Config::IniFiles 2.38. I am able to reproduce the same problem on Solaris 8 with Perl 5.8.0 and Config::IniFiles 2.38.
|