dragonchild has asked for the wisdom of the Perl Monks concerning the following question:
I anticipate having dozens of these sibling classes, so I don't want Base to have to have a sub is_(whatever) { 0 }. Each one only declares the sub is_(whatever) { 1 } that it is. I don't want to use isa() cause the classnames are much longer and it's just ugly. And, frankly, this should be do-able. But, I don't want AUTOLOAD to catch methods that aren't of the form /^is_/. I want it to fail as if it wasn't there.package Base; sub AUTOLOAD { (my $meth = our $AUTOLOAD) =~ s/([^:]+)$/$1/; if ( $meth =~ /^is_/ ) { return; } # ???? } package Foo; our @ISA = qw( Base ); sub is_foo { 1 } package Bar; our @ISA = qw( Base ); sub is_bar { 1 } # And so forth
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Redispatching AUTOLOAD for failure
by moritz (Cardinal) on Apr 14, 2008 at 20:58 UTC | |
|
Re: Redispatching AUTOLOAD for failure
by kyle (Abbot) on Apr 14, 2008 at 20:54 UTC | |
|
Re: Redispatching AUTOLOAD for failure
by ikegami (Patriarch) on Apr 14, 2008 at 21:07 UTC | |
|
Re: Redispatching AUTOLOAD for failure
by jhourcle (Prior) on Apr 15, 2008 at 01:44 UTC | |
|
Re: Redispatching AUTOLOAD for failure
by runrig (Abbot) on Apr 14, 2008 at 21:04 UTC | |
|
Re: Redispatching AUTOLOAD for failure
by rir (Vicar) on Apr 14, 2008 at 21:01 UTC | |
|
Re: Redispatching AUTOLOAD for failure
by lodin (Hermit) on Apr 15, 2008 at 14:56 UTC |