in reply to Re: Automated Slurp
in thread Automated Slurp
Not "also be written", but "better be written":
Not every code that would use this module wants the slurp routine aliased as main::slurp. Most times, calling code wants the slurp routine either in its own namespace or nowhere except in the Slurp:: namespace. Using Exporter (or one of the alternatives) would allow that, the original code doesn't. It should at least call the caller method to find out into which namespace the alias should be exported instead of blindly assuming main::. And it should create the alias inside the import routine, allowing use Slurp () to load the module without creating any alias.
Exporter is a huge load of code, and sometimes just overkill. The "tricks" from the Manual Exporting section of the Teflon Tape article shows how to export with less code. On the other hand, since so many modules use the Exporter, it is already in memory without extra costs most of the times, so writing own exporting code costs more than just using the Exporter and may create new bugs.
Alexander
|
|---|