I have some Perl code that uses require
instead of use
to load a specific module, and I have just discovered that my code requires a minimum version on that module. However, unlike use
, require
does not seem to have a version argument when loading a module. So what is the proper way to do this?
Asked
Active
Viewed 335 times
7

Ryan C. Thompson
- 40,856
- 28
- 97
- 159
-
Related: *[How can I find the version of an installed Perl module?](http://stackoverflow.com/questions/135755)* – Peter Mortensen Apr 16 '15 at 19:57
1 Answers
8
You can call for VERSION
method, it's inherited from the UNIVERSAL
class. It checks for $Module::VERSION
variable:
require Any::Module;
Any::Module->VERSION('2.3');

Suic
- 2,441
- 1
- 17
- 30
-
There is no point in using a `BEGIN` block if the original code doesn't have it. – Borodin Dec 02 '13 at 08:59