Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Subject says it all... O:-)
  • One signature for use is "use Module VERSION"

    You can use an expression for VERSION, even though the manual isn't crystal clear on that. A little testing goes a long way.

    print returns 1 on success, so you're trying to use that module with version 1 or more.
    • That makes sense. Now that I think about it, I don't know how I didn't get it at first...

      But come to think about it again, what about CPAN::Mini (version 0.20) and strict?

      Wait... strict was giving a different error...

      I need to get some sleep... over and out, back again sometime tomorrow... :-)
  • It all depends on the &import of a module.

    Lingua::Identify [] uses Exporter [] which considers the parameter a version number and croaks because it's higher than the module's.

    strict [] uses a custom importer which considers the number a non-existant pragma tag and croaks.

    In case noone else defines an &import, modules inherit &UNIVERSAL::import. Interestingly, that one does differentiate between a literal number and an expression:

    $ echo 'package Foo; our $VERSION = 0.1; 1;' >
    $ perl -le

  • You need a semi colon after the use statement.
    Without that you only have one statement:

    use strict   print "Hello World\n"

    The return of the print statement is 1 (unless it fails).
    This effectively changes it into use strict 1.0 , whereby the module is required to be at least version 1.0

    Of course your code should look like this:

    use strict;
    print "Hello World\n";
    • That was the precise point, the fact that the code would work some of the times without the semicolon :-)

      The part of the version one was taken care of pretty quickly [], but it took Aristotle [] to find out the reason for the exceptions [] (that is, modules below version 1 working and vice-versa).

      You wouldn't believe how ashamed of myself I am for not having solved the problem before posting it... oh well, one learns new things everyday :-)

      Anyway, if that's what it takes to bring a new user [] to the site, you ca