If I have a method called 'sane', and one called 'insane' that is defined in the XXX module, I want to do the followingsub new { my $proto = shift; # Get the Prototype my $class = ref ($proto) || $proto; # Make the Class Name my $parent= ref ($proto) && $proto; # Get the Parent Class + (if Any) my $self = {}; # Create the HASH for +the Object bless($self, $class); # Create the Object $self->{_PARENT}= $parent; $self->{_RESULT} = ""; # Result of the method + call $self->{_STATUS} = 0; # Status Return (0 = O +K) $self->{SERVER} = XXX->new(); return $self; # Return the Object Ref +erence } sub allowed_function { my $self = shift; my $function = shift; if ($function eq "sane") { return(1) ; } else { return(0); } } sub AUTOLOAD { my $self = shift; my $thing = $AUTOLOAD; $thing =~ s/.*:://g; return if $AUTOLOAD =~ /DESTROY$/; if ($self->allowed_function($thing) { $self->{SERVER}->$AUTOLOAD(@_); } }
I want the routine to execute, but if I saymy $X = XYZServer->new; my $sane; $sane = $X->sane;
I want it not to execute the routine !! I have been racking my brain oh how to do this, but it has me stumped.$sane = $X->insane;
In reply to Filtering access to an Objects functions by CTSMan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |