On 03/04/2015 09:12 PM, SSC_perl wrote:
Hi all,

        I'm just curious about something.  What's the difference between using

require 5.016;

or

use 5.016;

        The only thing I've seen is that if 5.16 isn't installed, 'use' outputs:

Perl v5.16 required--this is only v5.10.1, stopped at shop.cgi line 26.
BEGIN failed--compilation aborted at shop.cgi line 26.

while 'require' outputs this:

Perl v5.16 required--this is only v5.10.1, stopped at shop.cgi line 26.

        I know there's a difference when calling a module, but what about the 
version number?  Is it just semantics or is there something more to it?  My 
search hasn't revealed an answer.


it is more about when the check is done. use is done at compile time and require is done at run time. also use effectively calls require to load the module and then it may do importing as well. when a module is loaded it will run any use lines during its compile and require lines once the module is run. but from the point of view of the code that loaded that module both will cause failure if the version is not supported.

uri




--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to