my %_attribute_properties = ( _probeset_id => ['????', 'read.required'], ... _affy_align => [ ['????'] , 'read.write.noinit' ] _exons_map => [ { } , 'read.write.noinit' ] ... ); #### # AUTOLOAD Accesors if ($operation eq 'get') { # can i read the attribute? unless ($self -> _permissions ($attribute, 'read')) { die ("You don't have read permission for $attribute"); } # # Install accessor definition in the symbol table # How AUTOLOAD work: *{$VAR} give access to the symbol definition table so, # the second time that the method get_name is called AUTOLOAD isn't called cause # get_name is saved in the symbol table *{$AUTOLOAD} = sub { my ($self) = @_; unless ($self -> _permissions($attribute, 'read')) { die ("$attribute does not have read permission!"); } # get the attribute value # TIE-HASH da inserire qui # The attribute could be a scalar or a reference to an array or hash if (ref($self -> {$attribute}) eq 'ARRAY') { return @{$self->{$attribute}}; } elsif (ref($self -> {$attribute}) eq 'HASH') { return %{$self->{$attribute}}; } else { return $self -> {$attribute}; } }; }elsif ($operation eq 'set') { # Verify if you can set the attribute unless ($self -> _permissions($attribute, 'write')) { die ("$attribute does not have write permission!"); } # set the attribute value $self -> {$attribute} = $newvalue; # Install this mutator in the symbol table *{$AUTOLOAD} = sub { my ($self, $newvalue) = @_; unless ($self -> _permissions($attribute, 'write')) { die ("$attribute does not have write permission!"); } $self -> {$attribute} = $newvalue; }; } # Turn strict refs on use strict 'refs'; # Return the attribute value return $self -> {$attribute}; } # }}}