Hi, dear monks, I have a question about Perl packages. In part to solve namespace collision problems in mod_perl, I have to assign a package name to all of my objects and librairies. I've looked a lot on the web for complete answers on the correct way to do that, but some things are still confusing... I have the current dir configuration:
/myApp/cgi/login.cgi /myApp/config/webData.pm ---------------------------------------------------------- login.cgi: ---------------------------------------------------------- #!/usr/bin/perl use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); use lib "../config"; use webData qw(GetLinks); use strict; ... my $links_ref = MyPackages::Config::webData::GetLinks(); ---------------------------------------------------------- webData.pm: ---------------------------------------------------------- package MyPackages::Config::webData; use Exporter (); @ISA = qw(Exporter); @EXPORT_OK = qw(GetLinks GetEmails); use strict; ...
But what if I want to simply tell login.cgi:

my $links_ref = GetLinks();

instead of

my $links_ref = MyPackages::Config::webData::GetLinks();

Isn't there a way, in login.cgi header, to load the GetLinks function by it's complete package name, so that we can later in the file only use the short function name? And also, with the way I first described, I can access the GetEmails function by calling MyPackages::Config::webData::GetEmails(), even thought it wasn't listed in the use webData qw(GetLinks); list of keyword. What is the good, normal way to procede for applications like in this case?

In reply to Good package practices by joe_kool

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!
  • 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:
    & &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.