I'm looking at some legacy code for a web application where I work, trying to understand what it's doing, specifically with respect to a private namespace package.
Each webpage has it's own script (e.g., somepage.pl). Each of those scripts looks something like this:
#!/usr/bin/perl
use strict;
use Private;
#call a bunch of things to make a page
The 'Private.pm' module looks something like this:
# This is a private namespace where all modules get loaded.
# Warning: Don't put any 'use' statements that depend on Exporting int
+o a namespace you will actually use in the programs.
use strict;
use base_class1;
use base_class2;
use CGI;
use DBI;
# etc., loads lots of modules
A few other modules 'use' various packages, but mostly do not.
My Question:
What is this 'Private.pm' package doing for the program? Is it allowing main to find and access the other modules? Does it in any way allow the other modules to locate each other (perhaps through main)?
And, why do it this way?
Any enlightenment greatly appreciated!
Apprentice
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.