Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

ok, let's see if I can answer this without confusing myself in the process :-)

  1. 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.

  2. 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.

--
જલધર


In reply to Re: Understanding module structure and inheritance by jaldhar
in thread Understanding module structure and inheritance by bradcathey

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • 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:
    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
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (16)
    As of 2014-07-31 14:53 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (249 votes), past polls