in reply to Is this a good approach for reducing number of global variables?

Just on the idea that some scripts are too trivial to worry about globals.. I have had several 'trivial' scripts grow well beyond thier orignal intent. In those cases having the proper structure has been very helpful as I add more and more features to it.

Just my 1/50th of a dollar
  • Comment on Re: Is this a good approach for reducing number of global variables?

Replies are listed 'Best First'.
Re(2): Is this a good approach for reducing number of global variables?
by dmmiller2k (Chaplain) on Mar 19, 2002 at 17:45 UTC
    "I've had several 'trivial' scripts grow well beyond thier original intent."

    I continually find myself fending off the implicit patina of triviality assigned to Perl by users, evoked by the word 'script' (further bolstered by the impression, however accurate, that Perl is to UNIX what Visual Basic (et al) is to Windows).

    Nearly all the so-called 'one-off's I've ever written have somehow wound up either running in Production, or at least used on a regular basis ('soft' production, as it were). It has reached the point where I no longer use the word 'script' to refer to them when speaking to users, instead using the more substantive, 'program.'

    Toward that end I try ALWAYS to write my scripts/programs, however trivial, as though they are full-fledged applications (or soon will be). Which is to say I eschew globals, at the expense of passing values to subroutines more than perhaps efficiency would dictate.

    dmm

    If you GIVE a man a fish you feed him for a day
    But,
    TEACH him to fish and you feed him for a lifetime
Re: Re: Is this a good approach for reducing number of global variables?
by dragonchild (Archbishop) on Mar 19, 2002 at 14:43 UTC
    There are very few reasons to not do things the right way. If it's no skin off your back, then don't cut corners. "Shortcuts make for long journeys."

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.