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.
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".use constant database => "Repairs"; #the database name use constant hostname => "192.168.1.111"; #MySQL server IP address use constant port => '3306'; #MySQL port
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |