Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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. should be in a directory called Main. (:: is replaced by the directory separator for your particular OS.) 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 only imports (or 'uses') a symbol from 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 can still access it in its original namespace as Common::show_here. If you use Common in 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

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!
  • 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, 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

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

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (6)
    As of 2015-12-02 02:33 GMT
    Find Nodes?
      Voting Booth?

      My keyboard shows this many letters:

      Results (31 votes), past polls