Congrats on your first CPAN module!
This is more a nit than it is an operational fix, but I always prefer to see hash-based params passed in as a hash reference, as opposed to a hash:
this({ string => $string, times => 10, }); sub this { my $p = shift; # all params in hashref print $p->{string} x $p->{times}; }
I find it easier to track and organize things, and if you ever want to pass in another non-hash-based parameter later on down the road, it's much simpler than having to refactor your code to suit the new arg list. I wrote about this a few years ago.
my $href = { string => "Hello, world!" }; my $previous_error = $error; this($href, $previous_error); sub this { my $p = shift; # all params in hashref my $prev_error = shift; if (not $prev_error){ print $p->{string}; } }
Also, it might be worth setting some reasonable defaults instead of forcing the user to send in all parameters for every call:
this(); sub this { my $p = shift; $p->{hostname} = $p->{hostname} || "0.pool.ntp.org"; $p->{port} = $p->{port} || 123; }
-stevieb
In reply to Re: RFC: Net::SNTP::Client v1
by stevieb
in thread RFC: Net::SNTP::Client v1
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |