Use Vs Require in PERL

This is the next one for differences in Use Vs Require that adds to my series of posts such as  Differences IPv4 Vs IPv6, Differences Routing Vs Routed protocol, SMTP Vs ESMTP, Load Testing Vs Stress Testing and IMAP Vs POP3.

Use

Require

Loads module at compile time Loads module/libraries at runtime
Imports symbols/semantics from module only one time Avoids redundant loading of ‘require’d files/symbols multiple times
Errors can be handled inside module itself. Terminates program if there are errors in ‘require’d file or if file is not found.
  Use Module;
equivalent to,
BEGIN {
  require Module; 
  import Module ; }
require ‘Module.pm’
Does not require file extension to use file Requires file extension (.pm) to ‘require’ file.

If you are aware of any improvements to above differences or want to add to the above list then please post your comments below.

Note: We at TechSutram take our ethics very seriously. More information about it can be found here.
Mandar Pise Opinions expressed by techsutram contributors are their own. More details

Mandar is a seasoned software professional for more than a decade. He is Cloud, AI, IoT, Blockchain and Fintech enthusiast. He writes to benefit others from his experiences. His overall goal is to help people learn about the Cloud, AI, IoT, Blockchain and Fintech and the effects they will have economically and socially in the future.

No comments:

Post a Comment

    Your valuable comments are welcome. (Moderated)