I see that I inadvertently used #3 twice but, Yes, re-doing the command loop will solve the problem in #2.

If you mean the DB authentication, I would authenticate early and this "my $dbh" (database handle) will have package scope, a my $var at the top package level which cannot be exported to other modules (because it is a "my"), but yet would be visible to any sub in the package.

Even that you don't need to pass this to subs, I would pass the $dbh as a param to each "action" sub that needs it. The reason for that is to make it clear what each sub is using. You should wind up with a very small number of package level "real" variables. To further that I would suggest using the "constant" pragma.

use constant database => "Repairs"; #the database name use constant hostname => "192.168.1.111"; #MySQL server IP address use constant port => '3306'; #MySQL port
A constant is not a $variable and cannot be modified. You use it like a bareword (without any $ in front of it) in the actual code. I recommend this for package level things that are the "seldom changed, but important constants that might need to change in a different version of the program".

You should wind up with a very small number of package scoped "real variables" that the program changes during execution.

As far as Perl FORMAT goes, you will have to make up your mind about that as you write more code. It appears to work fine for strings, but when you want say exactly 2 decimal places for a currency number, this is not so good.

BTW, for this heading thing, there is no need for a FORMAT statement. A simple way is to use what is called a "here is" document.

#!/usr/bin/perl -w use strict; my $STDOUT_TOP= <<END_TOP; ID First Name Last Name Email Address Phone Number Dat +e Comp. Manufacturer Comp. Model Model Number OS ========== ========== ============ ================ ============ === + ======= ================== =========== ============ ============= END_TOP print $STDOUT_TOP;

In reply to Re^3: Trouble with an array inside a format call by Marshall
in thread Trouble with an array inside a format call by vendion

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.