1. If by "available" you just mean "callable", you can simply use the function's fully-qualified name:

    package SomePM; use OtherPackage; OtherPackege::some_func(); # works

    I sometimes do this in my projects for debugging:

    sub ::D { require Data::Dumper; return Data::Dumper::Dumper(@_) } sub ::DD { require Carp; Carp::confess(::D(@_)) } # later, call it like this: print ::D({ current_state => $state }); # debug print ::DD($state); # dump, stack trace, die.

  2. If you want some_func to be callable without qualification from any package... you can't do this generally and unevilly. :)

    If you have the cooperation of the other modules, have them use your module, and write an import routine to export your functions to the calling namespaces.

  3. If you don't have that cooperation, you might hook %INC (see require) to do this exploiting exporting for you. Note that unless you hook %INC early in the initialization of your program, you will probably have untreated modules already loaded in memory, and you will have to find out who they are and treat them post-fact. This of course will miss out on their BEGIN blocks.

In reply to Re: global function decleration by gaal
in thread global function decleration by Anonymous Monk

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.