| sub Requires # | ( | extension, | | | requirement, requirement, | | | requirement ... | ) | |
|
Adds external packages similar to if you used the line ‘require [package]’. This is similar to ‘use [package]’ except that nothing is exported, meaning you always have to use ‘package::function()’ instead of just ‘function()’. We don’t want an extension to potentially cause a naming conflict with Natural Docs’ functions, either now or in a future version.
All extension packages must call this function from BEGIN if they need to use external packages other than what is included in all Perl distributions by default. You can find a list of them at http://www.perldoc.com/perl5.005_03/lib.html.
Using this function instead of a direct ‘use [package]’ lets Natural Docs degrade gracefully if those packages aren’t there. If you just used ‘use [package]’ instead, Natural Docs would always quit with an error if that package wasn’t there, whether the user was trying to use your extension or not. Using this function instead only gives that error message if the packages aren’t installed and the user tried to use your extension anyway.
Parameters
| extension | The extension package. |
| requirement | The required external package. Specify as many times as you like. |
Example
NaturalDocs::Extensions->Requires(__PACKAGE__, 'String::CRC32', 'Crypt::Blowfish');