As others have said, "not like you are trying to".

I did however want to add a little bit of observation regarding this. Observe the following code, where the square-brackets indicate the name of the file the code is contained in:

[pm.pl] #!/usr/bin/perl -w use strict; use Foo; print CGI::header(); Bar::printme(); [Foo.pm] package Foo; use CGI; use Bar; 1; [Bar.pm] package Bar; sub printme { print "PRINTME FROM BAR \n"; } 1;
If you set up these packages you will notice that they run, and will print the header and the printme routine. However pm.pl never directly includes either CGI or Bar. The package routines are available via the package name::routine invocation method.
So you could do CGI::header() within your primary script.

However I personally would view this as a bad idea and sloppy coding. A script should never rely on another script to include a library it needs; Include the libraries you need. If you are worried about overhead of including a library multiple times, don't; Perl handles this and only uses/requires a library once, no matter how many times it is requested. There may be an exception or two to this rule, if anyone out there knows of them -- please speak up.


In reply to Re: Using a package within a package by Sifmole
in thread Using a package within a package by Red Neckerson

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.