You might consider moving many of those variables (ftp host, ftp user, email address, log directory, etc) into a configuration file. That would allow you to change these values in the future, without touching the source code. The config file could even be located in a place where your operations staff (if you have one) can modify it, allowing them to do things like update an email address without involving you at all.
I like to use Config::IniFiles (available on CPAN) for this purpose. I generally tie it to a hash, reducing the number of global variables that I have to keep track of.
Here's a sample config.ini file. It has separate values for testing and production, making it easy to switch from one to the other:
[prod] ftp_host = ftp.uslec.net ftp_user = cheese ftp_pass = whiz log_method = both def_email = someone@somewhere.com LOGFILE = /u20/home/gvc/log/something.log [test] ftp_host = ftp.uslec.net ftp_user = cheesetest ftp_pass = whiztest log_method = both def_email = someonetest@somewhere.com LOGFILE = /u20/home/gvc/log/somethingtest.log
Here's a sample code snippet:
use Config::IniFiles; our (%cfg); my %ini; tie %ini, 'Config::IniFiles', (-file => "config.ini"); %cfg = %{$ini{'prod'}}; print "I will FTP files to" . $cfg{ftp_host};
Wally Hartshorn
In reply to Configuration File
by Wally Hartshorn
in thread Compress and FTP files
by gnu@perl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |