Sounds like you might need a smart AUTOLOAD. Consider a scenario where you have a registry of "process functions" on disk, where the registry is a flat file database with pairs of "function-name, filename" as tuples. When AUTOLOAD is triggered, it scans this registry to locate the file that corresponds with a process function. When it finds one, it loads the file into a string, then evals it (as a sub definition) into the dataset's namespace.
This approach would let you (or others) write new process functions in files external to your main body of code. For extra credit, you could provide an option in your main script to use a different, "debug" registry that you would use for debugging new functions.
Here's an untested fragment, pieced together from pages 468-471 of the Cookbook.
Good lord, I just used a goto.sub AUTOLOAD { my $self = shift; my $attr = $AUTOLOAD; $attr =~ s/.*:://; # open the registry, search for $attr, # open assocated filename and load the # contents into $sub no strict 'refs'; *$attr = eval $sub; goto &$attr; }
In reply to Re: Possible Stupid Perl Trick - Importing method into object class?
by dws
in thread Possible Stupid Perl Trick - Importing method into object class?
by Masem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |