summaryrefslogtreecommitdiffstats
path: root/emergencyc.pl
diff options
context:
space:
mode:
authorDavid A. Madore <david+config@madore.org>2010-02-15 23:47:16 +0100
committerDavid A. Madore <david+config@madore.org>2010-02-15 23:47:16 +0100
commit7427c871abee6768cdd1c12d0ddf23f13cb37197 (patch)
treeefcc83e41376bc66d89856f2c27a76e24f7acea3 /emergencyc.pl
parente80e7f3c2289a93955ffeda6cf1a2e8e47eb351a (diff)
downloademergency-7427c871abee6768cdd1c12d0ddf23f13cb37197.tar.gz
emergency-7427c871abee6768cdd1c12d0ddf23f13cb37197.tar.bz2
emergency-7427c871abee6768cdd1c12d0ddf23f13cb37197.zip
Various stylistic improvements suggested by Max (such as using the // op).
Diffstat (limited to 'emergencyc.pl')
-rwxr-xr-xemergencyc.pl20
1 files changed, 4 insertions, 16 deletions
diff --git a/emergencyc.pl b/emergencyc.pl
index a7d55d2..b8bebb6 100755
--- a/emergencyc.pl
+++ b/emergencyc.pl
@@ -46,18 +46,8 @@ if ( defined($opts{K}) ) {
}
die "No key specified (use -K or -k option)" unless defined($key);
-my $host;
-if ( defined($opts{h}) ) {
- $host = $opts{h};
-} else {
- $host = "localhost";
-}
-my $port;
-if ( defined($opts{p}) ) {
- $port = $opts{p};
-} else {
- $port = DEFAULT_PORT;
-}
+my $host = $opts{h} // "localhost";
+my $port = $opts{p} // DEFAULT_PORT;
my @res = getaddrinfo($host, $port, AF_UNSPEC, SOCK_DGRAM)
or die "Cannot resolve host $host port $port";
@@ -72,10 +62,8 @@ sub curtime {
return sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ",$year+1900,$mon+1,$mday,$hour,$min,$sec);
}
-my $command = $ARGV[0];
-$command = "PING" unless defined($command);
-my $timestamp = $opts{t};
-$timestamp = curtime unless defined($timestamp);
+my $command = $ARGV[0] // "PING";
+my $timestamp = $opts{t} // curtime;
my $validate = "$command|$timestamp";
my $maccheck = hmac_sha256_hex($validate, $key);
send $socket, "$command|$timestamp|$maccheck", 0, $haddr;