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.)
or maybemy $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; } }
my $port = verify_port($value); sub verify_port { my $candidate = shift; if ( [suitable] ) { return $candidate; } else { (handle error case) (abort execution) } }
In reply to Re: RFC: Net::SNTP::Client v1
by Monk::Thomas
in thread RFC: Net::SNTP::Client v1
by thanos1983
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |