I'm trying to decide whether or not to use 'require' or 'do' in my scripts, to make maintenance easier.
At the moment I have 3 portions of a script that create each page. The first and last portions are the same for all pages, and the middle one is unique for all pages.
I'm trying to decide whether or not to make the first and last one into another file and use require or do, and call them as subroutines (so that I only have to modify 1 file, to affect all pages for the 1st and last half of the page) or if I should just leave it all in each file, and just have a lot more maintenance (having to modify every file, rather then just one) if I want to change something.
ie.
--- part 1 ---
--- part 2 ---
--- part 3 ---
for every single file.
vs.
--- require file 2 --- (OR the 'do' parts in the following)
--- 'do' part 1 --- (from file 2)
--- part 2 ---
--- 'do' part 3 --- (from file 2)
Basically, my questions are:
- How demanding would running two 'do' or one 'require' in a script be, vs. none at all? Is this somethign that could potentically create a tremendous strain on a server?
- What's the performance difference between 'do' and 'require'?
Just trying to do this right the first time, rather then having to recode it down the road because I didn't take the time to do it properly this time :-)
Any feedback is greatly appreciated!
Steny
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.