This may not be the standard way of doing things but I find that it works well for me. I just create a library file (not a module) and put all my subs in it. I use a .lib extension for these files to reduce confusion. You could use any extension you want though. Any way, create the .lib file and put your subs in there, including any
use statements for modules required by the subs. Be sure to put a valid statement outside any of the subs to keep perl from bombing out. I just put
1; as the last line of the library file. To use this library, put a
require '/path to file/file.lib'; in the main program. This will allow you to call any of the subs in the library file from the main program. There's my $.02 worth.
Library file example:
#!/usr/bin/perl
use Some::Module;
sub Sub1
{
... some code
return somevalue;
}
1;
Example main program:
#!/usr/bin/perl -w
use strict;
use warnings;
require '/path to library/libraryfilename';
my $test = Sub1(1,3,"a");
print $test;
exit;
Again, this is probably not the standard way of doing things but it very easy and quick.
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.