diff options
| author | 2015-03-08 01:59:59 +0400 | |
|---|---|---|
| committer | 2015-03-08 01:59:59 +0400 | |
| commit | c9fff1ee6bde3e5f345781556508bd4612dbd58a (patch) | |
| tree | 039b96c6174664aad3a514e53d66bc3570a9dc91 | |
| parent | d45c28ec36ebe67a632aad27989bb97a697e09fb (diff) | |
Use defined-or operator in some more places for clarity
e.g. $foo //= 'defaultvalue'
| -rw-r--r-- | modules/mysql.pl | 21 | ||||
| -rw-r--r-- | modules/util.pl | 2 |
2 files changed, 11 insertions, 12 deletions
diff --git a/modules/mysql.pl b/modules/mysql.pl index 85e0c6f..86a1c78 100644 --- a/modules/mysql.pl +++ b/modules/mysql.pl @@ -52,9 +52,8 @@ sub record { my $self = shift; my ($channel, $nick, $user, $host, $gecos, $level, $id, $reason) = @_; - if (! defined($gecos)) { - $gecos = "NOT_DEFINED"; - } + $gecos //= "NOT_DEFINED"; + my $dbh = $self->{DBH}; $dbh->do("INSERT INTO $self->{TABLE} (channel, nick, user, host, gecos, level, id, reason) VALUES (" . $dbh->quote($channel) . ", " . $dbh->quote($nick) . ", " . $dbh->quote($user) . @@ -112,20 +111,20 @@ sub actionlog return unless defined($action); # $bynick = lc $bynick if defined $bynick; #we will lowercase the NUHGA info later. if ( (defined($bynick)) && (defined($::sn{lc $bynick})) ) { #we have the nick taking the action available, fill in missing NUHGA info - $byuser = $::sn{lc $bynick}{user} unless defined($byuser); - $byhost = $::sn{lc $bynick}{host} unless defined($byhost); - $bygecos = $::sn{lc $bynick}{gecos} unless defined($bygecos); - $byaccount = $::sn{lc $bynick}{account} unless defined($byaccount); + $byuser //= $::sn{lc $bynick}{user}; + $byhost //= $::sn{lc $bynick}{host}; + $bygecos //= $::sn{lc $bynick}{gecos}; + $byaccount //= $::sn{lc $bynick}{account}; if (($byaccount eq '0') or ($byaccount eq '*')) { $byaccount = undef; } } # $nick = lc $nick if defined $nick; if ( (defined($nick)) && (defined($::sn{lc $nick})) ) { #this should always be true, else something has gone FUBAR - $user = $::sn{lc $nick}{user} unless defined($user); - $host = $::sn{lc $nick}{host} unless defined($host); - $gecos = $::sn{lc $nick}{gecos} unless defined($gecos); - $account = $::sn{lc $nick}{account} unless defined($account); + $user //= $::sn{lc $nick}{user}; + $host //= $::sn{lc $nick}{host}; + $gecos //= $::sn{lc $nick}{gecos}; + $account //= $::sn{lc $nick}{account}; if (($account eq '0') or ($account eq '*')) { $account = undef; } diff --git a/modules/util.pl b/modules/util.pl index cb66919..b3b612d 100644 --- a/modules/util.pl +++ b/modules/util.pl @@ -239,7 +239,7 @@ sub getNickIP if (defined($::sn{$nick}{ip})) { return $::sn{$nick}{ip}; } - $host = $::sn{$nick}{host} if (!defined($host)); + $host //= $::sn{$nick}{host}; my $ip = getHostIP(undef, $host); if (defined($ip)) { $::sn{$nick}{ip} = $ip; |
