CTSMan has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Filtering access to an Objects functions
by steves (Curate) on Feb 07, 2003 at 18:48 UTC | |
|
Re: Filtering access to an Objects functions
by adrianh (Chancellor) on Feb 07, 2003 at 21:27 UTC | |
|
•Re: Filtering access to an Objects functions
by merlyn (Sage) on Feb 07, 2003 at 18:33 UTC | |
by chromatic (Archbishop) on Feb 08, 2003 at 01:44 UTC | |
by adrianh (Chancellor) on Feb 07, 2003 at 21:34 UTC |