John M. Dlugosz > Exporter-VA > Exporter-VA-Convert

Download:
Exporter-VA-1.3.1.0.tar.gz

Annotate this POD

CPAN RT

New  2
Open  0
View/Report Bugs
Source  

NAME ^

Exporter-VA-Convert - Script to convert classic Exporter usage to Exporter::VA usage.

AUTHOR ^

John M. Dlugosz

SYNOPSIS ^

On the command line,

        Exporter-VA-Convert.perl [options] module-name

will produce a report of changes to make to that module. E.g.

        Exporter-VA-Convert.perl carp
        Exporter-VA-Convert.perl Sys::Hostname

The module-name parameter is the same as you would put in a use or require statement as a bareword.

options

With no options, it wil produce a direct translation. That is, the resulting usage of Exporter::VA will do the same thing as the original. If you're switching to Exporter::VA, you might be needing something beyond that, so optionally you can set up a more elaborate definition, for example to eliminate the default exports as of the current version, or set up for versioning.

There are no options implemented yet.

Instructions ^

This utility will load the module and examine the definitions of all the package globals used by the classic Exporter module. It will then generate a report telling you what to change to use Exporter::VA. It does not alter the code, since it doesn't directly parse the code. Rather, it only cares about the resulting values in the package globals after the module loads. The advantage is that it doesn't care how the values are computed, and does not limit your syntax or creativity.

@ISA

The occurance of Expoter in @ISA will be removed. If that was the only thing in there, it will instruct you to just remove the definition of @ISA. Otherwise, it tells you what's left. If Expoter was not listed at all, it will give you a warning as the subsequent results are dubious--did that module even use Expoter to begin with?

@EXPORT

You'll always be instructed to remove the definition for @EXPORT, since Exporter::VA doesn't use that. Instead, all the values will be incorporated into the export definition for Exporter::VA. A straight translation will make these members of the :DEFAULT tag as things that are exported by default. Command-line switches might change this behavior if you tell it to do something other than a direct translation.

@EXPORT_OK

You'll always be instructed to remove the definition for @EXPORT, since Exporter::VA doesn't use that. Instead, all the values will be incorporated into the export definition for Exporter::VA. All the names of things to be exported will be listed as a .plain field by default, since that is the simplest way to do this. Command-line switches might cause them to be individually listed instead, either because that's what you asked for or because something other than a direct translation needs more advanced features.

%EXPORT_TAGS

You'll always be instructed to remove the definition for @EXPORT, since Exporter::VA doesn't use that. Instead, all the values will be incorporated into the export definition for Exporter::VA. All of the tags will be reproduced as tag definitions in the export definition.

@EXPORT_FAIL

This is the only thing that is not translated exactly. Originally, I started generating results to emulate the mechanism exactly, calling your module's export_fail with the list of all failed items. That would allow it to be an exact plug-in replacement without having to otherwise affect your module.

However, the main reason for using @EXPORT_FAIL is as a primitive pragma/callback mechanism! If you really wanted to prevent something from being exported, simply don't list it as a possible export! The model for callbacks is easier to use in Exporter::VA, so this isn't translated exactly. Instead, it sets up the export definition for that callback and shows you the code skelleton for you to fill in. If your export_fail function switches on the items in the parameter list, you can simply copy the proper case to the new function, since you can get a callback to a different function on each pragmatic callback.

If you instead point all the callbacks to the same function, you can continue to switch off the supplied item. However, this will be called one at a time as they are being processed, as opposed to one call with a list of all the failing items at once.

%EXPORT

This is the single structure used for all the configuration details for Exporter::VA. Add this to your module by pasting it in.

HISTORY ^

v1.0 - exact translation only, no options. But handles all features of Exporter.

syntax highlighting: