Fixing the above gives us...
package Quote; use strict; use warnings; my (%phrase, %author, %approved); sub new { my ($class, $args) = @_; my $self; $self = bless [], ref $class || $class; if (ref $args eq "HASH") { $self->phrase() = $args->{phrase} if exists $args->{ph +rase}; $self->author() = $args->{author} if exists $args->{au +thor}; $self->is_approved() = $args->{approved} if exists $args->{ap +proved}; } $self; } sub phrase : lvalue { $phrase{(shift)}; } sub author : lvalue { $author{(shift)}; } sub is_approved : lvalue { $approved{(shift)}; } sub DESTROY { my $self = shift; delete $phrase{$self}; delete $author{$self}; delete $approved{$self}; } package QuotePlus; use base qw(Quote); use strict; use warnings; my(%date); sub new { my ($class, $args) = @_; my $self = $class->SUPER::new($args); if (ref $args eq "HASH") { $self->date() = $args->{date} if exists $args->{date}; } return $self; } sub date : lvalue { $date{(shift)}; } sub DESTROY { my $self = shift; $self->SUPER::DESTROY(); delete $date{$self}; }
Which I think does what you want.
In reply to Re: (my?) problem with re-blessed references(?)
by adrianh
in thread (my?) problem with re-blessed references(?)
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |