Subject: | errstr(); doesn't work due to typo in SYNOPSIS |
Dear Adam,
When using Config::Tiny like so, as per SYNOPSIS:
#!/usr/bin/perl -w
use strict;
use warnings;
use Data::Dumper;
use Config::Tiny;
# Create a config
my $Config = Config::Tiny->new();
# Open the config
$Config = Config::Tiny->read('');
print Dumper( $Config );
my $error = $Config->errstr();
print $error, "\n";
I get an error message of:
$VAR1 = undef;
Can't call method "errstr" on an undefined value at test.pl line 17.
Is this correct? According to the docs, it should be possible:
"errstr
When an error occurs, you can retrieve the error message either from the
$Config::Tiny::errstr variable, or using the errstr() method."
However, this works fine:
print $Config::Tiny::errstr, "\n";
Which gives:
"You did not specify a file name"
The solution is not to use the example in the SYNOPSIS:
# Open the config
$Config = Config::Tiny->read( 'file.conf' );
But use instead:
# Open the config
$Config->read( 'file.conf' );
Then $Config->errstr(); works fine.
I've added a patch to save you typing ;-)
Thanks,
Gavin.
Subject: | SYNOPSIS.patch |
--- Tiny.pm 2005-12-30 21:41:15.000000000 +0000
+++ Tiny.pm.new 2006-02-02 10:07:34.000000000 +0000
@@ -133,7 +133,7 @@
my $Config = Config::Tiny->new();
# Open the config
- $Config = Config::Tiny->read( 'file.conf' );
+ $Config->read( 'file.conf' );
# Reading properties
my $rootproperty = $Config->{_}->{rootproperty};