I just wanted to know about the advantages and disadvantages of "require" over "use" in Perl.
I know that :
1. "use" is evaluated at compile time and "require" at run-time.
2. If the module I am using with "use" has syntax error they will be thrown while compiling, on the contrary if the module is "require" ed then they will come during run-time and no errors will be reported in compile time.
3. When we do "use", the control is passed to that file at run-time and whereas in case of "require" the code from that module/file is included to my code which is "require"ing it at run-time.
4. If I have a module which does a lot in the BEGIN block and I don't really need it in all cases , then it is clever to "require" it so that I won't have to wait for all the initializations of that module in case I don't need it.
My question is :
is there any gain in terms of memory consumption when I use "require" or any other advantage ? Please let me know.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||