ok, let's see if I can answer this without confusing myself in the process :-)
First the easy question: yes this is the kind of layout I and I would say most CGI::Application use too. It's a bit safer if your code packages or templates are not in an area accessible to the web server. However you've got some errors.
Contact.pm should be in a directory called Main. (:: is replaced by the directory separator for your particular OS.)
Main.pm doesn't need the shebang line but does need one which says package Main;
In calling.cgi use Main::Contact not Contact::Contact.
- Internally a perl script has a table of symbols including subroutine names. These are partitioned into namespaces or "packages." Contact inherits Main. That means the Contact namespace will also include a copy of all the symbols of the Main namespace plus whatever it defines for itself. However Main.pm only imports (or 'uses') a symbol from Common.pm. That means within the symbol table for that file, there is an entry called Common::show_here. That symbol is not part of the Main:: namespace so doesn't get inherited along with other Main:: symbols in Main::Contact. However Contact.pm can still access it in its original namespace as Common::show_here. If you use Common in Contact.pm you can leave out the Common:: part and get the same result.
Update: friedo is right and I have oversimplified far too much. What I am trying to get is that when you inherit a class that classes symbols are "yours" whereas with "use" the symbol remains "foreign" in a way though it is available to you. Hope this is clearer.
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:
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.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||