Subject: | wacky config causes config::auto to barf |
If you give it a config file that looks like this:
[part one]
This: is garbage
You'll get:
Use of uninitialized value in numeric gt (>) at
/users/fbicknel/lib/Config/Auto.pm line 139, <$config> line 3.
at /users/fbicknel/lib/Config/Auto.pm line 139
Config::Auto::score('ARRAY(0x3f9b50)') called at
/users/fbicknel/lib/Config/Auto.pm line 69
Config::Auto::parse('config') called at tryConfigAuto line 7
If you initialize %score (or there are numerous other solutions):
sub score {
my $data_r = shift;
return (xml => 100) if $data_r->[0] =~ /^\s*<\?xml/;
return (perl => 100) if $data_r->[0] =~ /^#!.*perl/;
my %score = (
bind => 0,
colon => 0,
colonequal => 0,
equal => 0,
ini => 0,
irssi => 0,
list => 0,
perl => 0,
space => 0,
xml => 0,
yaml => 0,
);
for (@$data_r) {
... then you get clean results. The above invalid config file just
returns an undef in this case.
Hope this helps!