G'day bishop729,

Welcome to the Monastery.

If a module is installed, you can simply put

use Some::Module;

in your code (see use for some variations on that syntax).

If you don't want your users to have to install anything, you can put the module source in your repo. Something like this:

bin/ script.pl lib/ Some/ Module.pm

You can use FindBin so your code can find the module.

Be aware that you'll need to keep copies of Some::Module in all repos; all fixes, enhancements, extensions, etc. will need to be kept in sync across all repos. This tends towards a maintenance nightmare and I certainly don't recommend it; however, if it's a requirement that users don't install modules, this is probably what you'll need to do.

I don't know how familiar you are with writing modules. I'd recommend using Exporter to avoid namespace pollution. Your code might look something like this:

package Some::Module; use strict; use warnings; our $VERSION = '0.001'; use Exporter 'import'; our @EXPORT_OK = qw{isnum isint isfloat}; our %EXPORT_TAGS = (all => [@EXPORT_OK]); sub isnum { ... } sub isint { ... } sub isfloat { ... } 1;

And don't forget to add your POD after that.

See also:

— Ken


In reply to Re: Portable way of checking if a scalar is a number / integer / float by kcott
in thread Portable way of checking if a scalar is a number / integer / float by bishop729

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.