Skip Menu |

This queue is for tickets about the Config-General CPAN distribution.

Report information
The Basics
Id: 42721
Status: resolved
Priority: 0/
Queue: Config-General

People
Owner: tlinden [...] cpan.org
Requestors: fbicknel [...] nc.rr.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 2.42
Fixed in: (no value)



Subject: Config items with no values should return undef
Config items of the form: IAMUNDEF as opposed to IAMDEF = '' ...are indistinguishable insofar as the value returned by Config::General. It would be better to return undef in the former case rather than ''. This lets one act differently based on whether the config item was truly undefined or if an empty string was assigned. For example, my configuration rule is that if you mention an item with no arguments, you get a boolean 'true' value. Adding 'NO' to the front gives you a boolean 'false' value. (Admittedly one has trouble with a config item like "NOSE", but that's a different story.) I am not allowing empty strings, so it works ok for me as it is. But it seems a worthwhile improvement.
fixed in 2.43
RT-Send-CC: demerphq [...] gmail.com
On Wed Jul 15 14:23:04 2009, TLINDEN wrote:
Show quoted text
> fixed in 2.43

I think this is a regression tho. I have a config file where i get a stream of warnings like this:

Use of uninitialized value in pattern match (m//) at /home/yorton/localperl/lib/site_perl/5.8.9/Config/General.pm line 1053.

When i traced into the code i found this:

  # avoid "Use of uninitialized value"
  if (! defined $value) {
    $value = undef; # bigfix rt.cpan.org#42721  q();
  }

  if ($this->{InterPolateVars}) {
    $value = $this->_interpolate($config, $option, $value);
  }

  # make true/false values to 1 or 0 (-AutoTrue)
  if ($this->{AutoTrue}) {
    if ($value =~ /$this->{AutoTrueFlags}->{true}/io) {
      $value = 1;
    }
    elsif ($value =~ /$this->{AutoTrueFlags}->{false}/io) {
      $value = 0;
    }
  }

Now, if the first block is correct, and i dont think it can be, then it is a no op, so it might as well just be deleted.

However, if the logic remains, code deleted or not, then there is the problem of the undefined value in the next block regardless.

Possibly it should be guarded by defined check on $value, but then how do you use AutoTrueFlags to deal with an undef value?

It is not clear to me what the correct behaviour should be or I would supply a patch.

As an aside the /o on those patterns is dodgy and should be removed.

cheers,
Yves


Hi, the patch in bug#54583 seems to fix this one too. I'll try it out these days.
fixed in 2.45. Thanks for the work! It helped a lot!