Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: RFC: Net::SNTP::Client v1

by Monk::Thomas (Friar)
on Jul 01, 2015 at 15:26 UTC ( [id://1132846]=note: print w/replies, xml ) Need Help??


in reply to RFC: Net::SNTP::Client v1

my $client_socket = new IO::Socket::INET ( [stuff] ) or die && return ( [other stuff] );

I am pretty sure the return is totally useless because die will terminate your program and that's it. Apart from that due to your indentation style it's pretty hard to determine whether you're actually in a returnable function or not.

Additionally:

my $checkPort = sub { my $port = shift; if ($port) { if ($port > MAX_PORT or $port < MIN_PORT){ $error = "Please insert a correct port number (".MIN_PORT." - +".MAX_PORT.")"; return TRUE; } } else { $moduleInput{-port} = 123; return FALSE; } };

a) Decide to use a specific indentation style and then stick to it. The outer if-conditional has its codeblock indented, the inner one does not. That's very confusing.

b) Using a 'true' value to indicate an error and a 'false' value to indicate success is counter-intuitive. Using '0' or 'undef' as the error-returns opens up the possibility to use the return value to provide more detail. (e.g. number of returned matches, length of read data, in your case it could be used to indicate the actual port used in case the default applies.)

my $port = verify_port($value); if (defined $port) { (do stuff) } else { (handle error case) } sub verify_port { my $candidate = shift; if ( [suitable] ) { return $candidate; } else { return; } }
or maybe
my $port = verify_port($value); sub verify_port { my $candidate = shift; if ( [suitable] ) { return $candidate; } else { (handle error case) (abort execution) } }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1132846]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2024-04-24 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found