OK,

Over the last serveral data processing scripts, I've been refining my style and noticed several patterns. Now, I'm in the process of building a template script which should speed up the writing of future scripts. I'll update the older scripts, too, so things are consistent and easily maintained. And to that end I have a question or two.

Yesterday on the CB, we were discussing strict and that globals were verbotten except for those declared in packages... is that to say that it is exceptable create a package for the purpose housing global variables? I was standing in the shower thinking that declaring all of my general use variables at the top would make the scripts look like my old pascal programs and it occurred to me that maybe I could put some of the things I use in every script (ftp handle, dbi handle, machine name, remote path, local path, etc) in a package and neaten things up a bit.

All of my scripts pretty much do the same thing:

  • ftp connect to a remote machine
  • get a listing
  • download the files to the incoming directory
  • coalate data if necessay
  • establish DB connection
  • close connections
  • exit
  • Does it make sense to build a genric script and force the differences out to functions in packages with overloaded names? For example: the template might call the sub "process_line" which would be a different sub based on which network element's package was loaded (NE::WSB, NE::SMSC, etc).

    I haven't really thought this entirely through... but I've been thinking and that can be a dangerous thing :)

    Thanks

    Jimbus

    Never moon a werewolf!

    In reply to Of strict, globals, packages and style by jimbus

    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.