Namespaces are a great gift, and I'd recommend to using them :) Why don't you just place your standard library in an includable module (I usually name them MyProject::Utils or such) and use Exporter's functionality to import the wanted subroutines into the requesting namespace?(1)
Like choedebeck pointed out, require will load the file only once. You might want to use 'do' for a quick solution, tho I'd recommend the Exporter version.
1. (untested, see perldoc
Exporter for more)
package MyProject::Utils;
use warnings;
use strict;
use base qw/ Exporter /;
use vars qw/ @EXPORT_OK /;
@EXPORT_OK = qw/ mysub_foo mysub_bar /;
sub mysub_foo { ... }
sub mysub_bar { ... }
...
use MyProject::Utils qw/ mysub_bar /;
my $x = mysub_bar( 23 );
Ordinary morality is for ordinary people. -- Aleister Crowley
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.