If you are using lexical variables as globals, then use vars - that is what it is for.

Also if you can you want to move the bulk of the functions in question into their own modules. When your script runs it can then load the module and call functions from there. Why?

  1. Shared warnings go away.
  2. There is less work required per invocation of your script.
  3. I believe you will consume less memory.

OK, so it will separate code into different files, and that does tend to require more thought. The basic template I would suggest using looks something like this. If your module is MyStuff.pm, then start it like this:

package MyStuff; @ISA = 'Exporter'; @EXPORT_OK = qw(really neat functions here); use strict; # etc, including those neat functions 1; # An unfortunately necessary annoyance
And then you use it like this:
use MyStuff qw(neat functions); # Whatever you actually need # Proceed to call "neat" and "functions like normal # functions. You only get the ones which you list. This # is a GOOD thing because it makes it easier to track down # which function came from where!
This is your basic procedural module. While writing it, it is good to put some thought to how to reuse the functions elsewhere...

In reply to Re (tilly) 5: How to call other programs by tilly
in thread How to call other programs by Jonathan

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.