In looking over your code, I thought I'd just make a couple of suggestions that may help you with future programs:
- You don't need to quote simple scalars to use them. For example: "$foo" can be simply $foo as the quotes are used to add things or combine scalars, such as "$foo$bar" or "${foo}s". The quotes are harmless in most cases, so it's nothing to worry about, but it looks odd.
- Throwing things, like comments, around your subroutine declarations is highly unconventional. In this case, I think it degrades readability, since many are used to seeing them less decorated. You'll note that despite similar formatting, you have a case where one is a subroutine declaration, and the other is a code BLOCK.
- Instead of using a constant, you might want to use a subroutine parameter. Something like this:
sub move_logs
{
my ($logs, $target_path) = @_;
# : (etc.)
}
# ...
my $log_path = '\\\\10.1.1.5\\Weblogiclogs\\'
. strftime( '%y%m%d%H%M', localtime);
my $logs = "\\\\192.168.2.5\\Weblogiclogs\\*.log";
move_logs($logs, $log_path);
- One of the reasons for this restructuring is that it keeps the distance between the declaration of the variable and its use to a minimum. This makes it easier to find out what it is, without having to scroll all over the place. Imagine there was 1500 lines between the top and bottom of your program, which is not uncommon.
- You may have to expand your $logs file spec into a list of files using glob and iterate over it. Something like:
foreach my $file (glob($logs))
{
move($log, $log_path) || die "screaming";
}