in reply to Re: Problem with Class
in thread Problem with Class and AUTOLOAD with GTK
If I create my hard coded setters and getters in module Page.pm, the problem don't arise. If I use my Autoload.pm the problem arise. ps. I modified the title in "Problem with Class and AUTOLOAD with GTK"package Autoload; use Locale::TextDomain ("kapello.it.$main::PROGRAM"); use Exporter; @ISA = qw (Exporter); @EXPORT = qw(AUTOLOAD); use Carp; sub AUTOLOAD{ my ($self, $newval) = @_; # Costruisco il metodo get if ($AUTOLOAD =~ /.*::get_(\w+)/){ my $property_name = $1; my $ref = ref($self->{$property_name}); if ($ref eq 'ARRAY'){ *{$AUTOLOAD} = sub { @{$self->{$property_name}} }; return @{$self->{$property_name}}; } else{ *{$AUTOLOAD} = sub { $self->{$property_name} }; return $self->{$property_name}; } } # Costruisco il metodo set if ($AUTOLOAD =~ /.*::set_(\w+)/){ my $property_name = $1; *{$AUTOLOAD} = sub { $self->{$property_name} = $newval }; return $self->{$property_name} = $newval; } # Deve esserci un errore croak __"Il metodo: $AUTOLOAD non è disponibile."; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Problem with Class
by lamprecht (Friar) on Jan 03, 2011 at 19:09 UTC | |
by kapello (Initiate) on Jan 03, 2011 at 20:00 UTC |