in reply to Dynamic names
Just so you know, this code:
&{$animal."::speak"};
doesn't create anything. It uses what's called a "symbolic reference" to look up a subroutine that already exists. A symbolic reference is just a string, and when you try to dereference a string, {}, perl looks up the string in the symbol table, and in this case retrieves the subroutine, &, with that name.
You can use typeglobs to create new entries in the symbol table, for instance:
*Cow::speak = sub {print "mooo\n"}; Cow->speak(); --output:-- mooo
The rest of your post doesn't make any sense to me.
|
|---|