I think that the stucture of this script is excellent! Adding command line argument support should be a breeze now (hint! hint!). However, i would change the name of the subroutine Main to something more descriptive like fetch_message or just fetch. (and lower case is nicer!)
Off topic, i advise against re-using variables like you do with this snippet:
Taken out of context like that, you hopefully see that this really is not good. It was a string, now it's an object - this is the kind of practice that results in hard to track bugs. Better to just be safe and decouple:my $url = "ftp://$id:$pw\@$dom/logs/"; $url = new URI::URL("$url/$logweb");
Also (and i say this because i have been corrected on this as well), if a subroutine returns a value, return the value:my $site = "ftp://$id:$pw\@$dom/logs"; my $url = new URI::URL("$site/$logweb");
And this doesn't just go for this subroutine, adding returns to your Main function is highly recommended. Sure Perl evaluates the last expression and returns it, but saying that with an explicit return says a lot more to others trying to understand the script (especially if they are Perl newbies coming from another language).sub Yesterday { # sidetrack: following golf just a thought ... my($yy, $ym, $yd) = Add_Delta_Days(Today(), -1); return sprintf "%04d-%02d-%02d", $yy, $ym, $yd; }
Other than those nit-picks, i say nice work ybiC...
UPDATE
...but also heed chromatic's wisdom!
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) Re: Is this a good approach for reducing number of global variables?
by jeffa
in thread Is this a good approach for reducing number of global variables?
by ybiC
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |