r54328 - /trunk/dh-make-perl/lib/Debian/Control/Stanza.pm
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Sun Mar 14 17:31:49 UTC 2010
Author: dmn
Date: Sun Mar 14 17:31:43 2010
New Revision: 54328
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=54328
Log:
Control::Stanza: construct like an instance of Tie::IxHash
This allows using Tie::IxHash methods
We already override Class::Accessors' get() and set()
methods
Modified:
trunk/dh-make-perl/lib/Debian/Control/Stanza.pm
Modified: trunk/dh-make-perl/lib/Debian/Control/Stanza.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/Debian/Control/Stanza.pm?rev=54328&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/Debian/Control/Stanza.pm (original)
+++ trunk/dh-make-perl/lib/Debian/Control/Stanza.pm Sun Mar 14 17:31:43 2010
@@ -78,9 +78,8 @@
my $class = shift;
my $init = shift || {};
- my $self = {};
-
- tie %$self, 'Tie::IxHash';
+ my $self = Tie::IxHash->new;
+
bless $self, $class;
while( my($k,$v) = each %$init ) {
@@ -202,7 +201,7 @@
$field =~ s/_/-/g;
- return ( tied %$self )->FETCH($field);
+ return $self->FETCH($field);
}
=item set( $field, $value )
@@ -227,7 +226,7 @@
$value = Debian::Control::Stanza::CommaList->new($value)
if not ref($value) and $self->is_comma_separated($value);
- return ( tied %$self )->STORE( $field, $value );
+ return $self->STORE( $field, $value );
}
=item as_string($width)
@@ -249,9 +248,10 @@
my @lines;
- while( my($k,$v) = each %$self ) {
+ for my $k ( $self->Keys ) {
# We don't' want the internal fields showing in the output
next if $k =~ /^-/; # _ in fielld names is replaced with dashes
+ my $v = $self->FETCH($k);
next unless defined($v);
next if $self->is_dependency_list($k) and "$v" eq "";
next if $self->is_comma_separated($k) and "$v" eq "";
More information about the Pkg-perl-cvs-commits
mailing list