Subject: | Config::Ini Sets $! to 2 even when successful |
Hi,
I've been using your Config::Ini module and discovered a side-effect bug.
After the an $ini object goes out of scope $! is set to 2 even when all operations were successful. This wouldn't normally be a problem except that I was foolishly relying on "die" to return errorlevel 255. After I RTFM I discovered that die returns 255 only if $! == 0 otherwise it returns $!.
Here's a simple example.
####################
use Config::Ini;
sub test {my $ini = new Config::Ini()}
print "\$! was \[$!\]\n";
test;
print "\$! is now \[$!\]\n";
####################
D:\>test.pl
$! was []
$! is now [No such file or directory]
D:\>
I don't understand the ins and outs of object oriented perl, but according to the PDK debugger, Autoloader.pm tries to "goto &$sub" at line 109. At this point $sub eq "Config::Ini::DESTROY". As this sub is not defined in Ini.pm, perl sets $! to 2.
By adding a null DESTROY sub into ini.pm the example code works fine.
sub DESTROY {}
Please advise if this is not a recommended fix.
Cheers,
Alistair
PS I've also given up on trusting in die to return the error codes I require and will explicitly use exit(n).
PPS. Here's my config details
ActiveState Perl, v5.6.1 build 633
Config::Ini Version v1.08
Windows XP (not SP1 ye).
Config::Ini was installed via PPM and the ActiveState binary repository
http://www.activestate.com/PPMPackages/zips/6xx-builds-only/
on 16-Oct-02 at 16:59 GMT