Skip Menu |

This queue is for tickets about the Data-Properties CPAN distribution.

Report information
The Basics
Id: 43307
Status: new
Priority: 0/
Queue: Data-Properties

People
Owner: Nobody in particular
Requestors: Assa.Lahav [...] comverse.com
Cc:
AdminCc:

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



CC: <bcm [...] maz.org>
Subject: Bug in Data::Properties
Date: Sun, 15 Feb 2009 12:56:49 +0200
To: <bug-Data-Properties [...] rt.cpan.org>
From: "Lahav Assa" <Assa.Lahav [...] comverse.com>
Hi. I found a bug in Data::Properties. When a key holds a '0' value, it is not returned by the 'get_property()' method. For example, when my.properties has this content: a=0 b=1 c=2 And I run this script: #!/usr/bin/perl use Data::Properties; my $props = Data::Properties->new(); open FH, "./my.properties" or die "can't open my.properties: $!\n"; $props->load(\*FH); close FH; for my $name ($props->property_names()) { my $val = $props->get_property($name); print "$name=$val\n"; } I get this output: c=2 a= b=1 I fixed 'get_property' method as follows: sub get_property { my ($self, $key, $default_value) = @_; $default_value ||= ""; return $default_value unless $key; return $self->{_props}->{$key} if ($self->{_props}->{$key} || $self->{_props}->{$key} eq "0"); return $default_value unless $self->{_defaults}; return $self->{_defaults}->get_property($key); } And then it worked. Assa Lahav