in reply to XML Navigator
Neat.
I think you could replace:
if ($pspec->get_name eq 'collapsed_box_height') { return $self->{collapsed_box_height}; } elsif ($pspec->get_name eq 'collapsed_box_width') { return $self->{collapsed_box_width}; } elsif ($pspec->get_name eq 'full_box_height') { return $self->{full_box_height}; } elsif ($pspec->get_name eq 'full_box_width') { return $self->{full_box_width}; } elsif ($pspec->get_name eq 'insets') { return $self->{insets}; } elsif ($pspec->get_name eq 'domdocument') { return $self->{domdocument}; } elsif ($pspec->get_name eq 'matrix') { return $self->{matrix}; } elsif ($pspec->get_name eq 'max_hori_distance') { return $self->{max_hori_distance}; } elsif ($pspec->get_name eq 'max_vert_distance') { return $self->{max_vert_distance}; }
with something like:
my %props = map { $_->{name} => 1 } $self->list_properties; return $self->{$pspec->get_name} if exists $props{$pspec->get_name};
or even simply:
return $self->{$pspec->get_name} if exists $self->{$pspec->get_name};
Most of SET_PROPERTY is like that too. And
my $draw = shift; my $gc = shift; my $text = shift; my $x = shift; my $y = shift; my $w = shift; my $h = shift;
Yuck.
my ($draw, $gc, $text, $x, $y, $w, $h) = @_;
or
my %args; @args{qw(draw gc text x y w h)} = @_;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: XML Navigator
by rstarr (Initiate) on Sep 30, 2006 at 17:06 UTC |