Sounds like what you need is a generic data access method.
If so, then use AUTOLOAD. AUTOLOAD() is a proxy method that is called
if a method is not defined.
Here is some code....
#!/bin/perl
foo();
goo();
sub AUTOLOAD()
{
print "$AUTOLOAD is here...what can I do for you\n";
}
Note I never defined foo() or goo().
Isn't Perl cool...
On Fri, 17 Aug 2001, Billy Patton wrote:
> I have an OO module that has some 100+ slots in the hash.
> most are all for holding command line input. Any command
> line switch get entered into the hash without the -
> ex: command_line -abc -def
> is abc and def in the hash.
>
> Keeping with good OO methodology I need a method to access each element
> without building a method for each.
> EX:
> sub abc {
> my ($c,$set) = @_;
> my $name = (caller(0))[3];
> $c->{$name} = $set if defined $set;
> return $c->{$name};
> }
>
> in an XS file I have :
> OnlyArb(np,stop=0)
> Laff::Node np
> Laff::Node stop
> ALIAS:
> OnlyArb = lARB
> OnlyAttr = lATTR
> OnlyCircle = lCIRCLE
> OnlyClf = lCLF
> OnlyConnect = lCONNECT
> OnlyCpd = lCPD
> OnlyCpr = lCPR
> OnlyDtext = lDTEXT
> OnlyName = lNAME
> OnlyPath = lPATH
> OnlyPort = lPORT
> OnlyPrel = lPREL
> OnlyRect = lRECT
> OnlySnam = lSNAM
> OnlySxcall = lSXCALL
> OnlyText = lTEXT
> OnlyXcall = lXCALL
> CODE:
> {
> do
> {
> np = (stop) ? LaffNodeNext(np,stop)
> : LaffNodeNext(np,NULL);
> } while (np && np->type != ix);
> RETVAL = np;
> }
> OUTPUT:
> RETVAL
>
> This gives me one routine that I can access all data. ix is the l*
>
> How can I do this in my OO package?
>
> I've looked out on CPAN and searched for Alias. There is an alias
> module
> but they deal with data, not subroutines.
>
> So how do I duplicate teh ALIAS and ix in perl for what has been done
> in XS?
>
>
--
-------------------------------------------------------------------------
Medi Montaseri [EMAIL PROTECTED]
Unix Distributed Systems Engineer HTTP://www.CyberShell.com
CyberShell Engineering
-------------------------------------------------------------------------