I already /msg'ed this, but i should probably reply for the benefit of other readers. Check out A Guide to Installing Modules for info on how to install modules on servers you do not have root access for.

As for use vars drop the commas in qw():

use vars qw/foo bar baz/;

And finally, global variables ... yes they are generally considered bad design, but sometimes they can provide elegance that is, IMHO, worth more than the trouble not using them causes. The important thing is to not rely upon them heavily. I tend to favor OO for larger programs, but in a sense, an attribute is a global variable for an object. An object is just a convenient way to tuck away that variable/attribute when you don't need it. Consider a framework that 'HAS-A' database connection abstracted away in a object heirarchy somewhere:
# some base class that overrides a handler sub handle { my ($self) = @_; my $dbh = $self->{dbh}; my $ses = $self->{session}; my $sth = $dbh->selectall_arrayref(" select id from agents "); my $users = [map { {user => $_->[0]} } @$sth]; my $paramsout = {users => $users}; return $paramsout; }
(look familiar, maverick? ;))

Here, making the database connection accessible as an attribute from an object not only makes more sense, it is necessary to keep 'things from getting out of hand'. But for small-ish utility scripts, this kind of abstraction is really overkill that gets it the way of 'getting stuff done'. Happy coding. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) 3Re: Code review and question for parts script by jeffa
in thread Code review and question for parts script by bprew

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.