3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-23 04:19:27 +01:00

Fix "keys on scalar" deprecation warning on newer perl. (#3)

This patch fixes the warning "Experimental keys on scalar is now
forbidden" which appears when running pbot on newer versions of perl.
This commit is contained in:
Tomasz Kramkowski 2017-04-11 03:55:52 +01:00 committed by Pragmatic Software
parent f65f6df116
commit 382e47d971
6 changed files with 13 additions and 12 deletions

View File

@ -111,7 +111,7 @@ sub adminrem {
if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) { if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) { if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) {
foreach my $mask (keys $self->{pbot}->{admins}->{admins}->hash->{$channel}) { foreach my $mask (keys %{ $self->{pbot}->{admins}->{admins}->hash->{$channel} }) {
if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) { if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) {
$hostmask = $mask; $hostmask = $mask;
last; last;
@ -143,7 +143,7 @@ sub adminset {
if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) { if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) { if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) {
foreach my $mask (keys $self->{pbot}->{admins}->{admins}->hash->{$channel}) { foreach my $mask (keys %{ $self->{pbot}->{admins}->{admins}->hash->{$channel} }) {
if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) { if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) {
$hostmask = $mask; $hostmask = $mask;
last; last;
@ -171,7 +171,7 @@ sub adminunset {
if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) { if (exists $self->{pbot}->{admins}->{admins}->hash->{$channel}) {
if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) { if (not exists $self->{pbot}->{admins}->{admins}->hash->{$channel}->{$hostmask}) {
foreach my $mask (keys $self->{pbot}->{admins}->{admins}->hash->{$channel}) { foreach my $mask (keys %{ $self->{pbot}->{admins}->{admins}->hash->{$channel} }) {
if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) { if ($self->{pbot}->{admins}->{admins}->hash->{$channel}->{$mask}->{name} eq $hostmask) {
$hostmask = $mask; $hostmask = $mask;
last; last;

View File

@ -328,7 +328,7 @@ sub remove {
delete $self->hash->{$primary}->{$secondary}; delete $self->hash->{$primary}->{$secondary};
# remove primary group if no more secondaries # remove primary group if no more secondaries
if(scalar keys $self->hash->{$primary} == 0) { if(scalar keys %{ $self->hash->{$primary} } == 0) {
delete $self->hash->{$primary}; delete $self->hash->{$primary};
} }

View File

@ -124,7 +124,7 @@ sub remove_factoid {
delete $self->{factoids}->hash->{$channel}->{$trigger}; delete $self->{factoids}->hash->{$channel}->{$trigger};
if(not scalar keys $self->{factoids}->hash->{$channel}) { if(not scalar keys %{ $self->{factoids}->hash->{$channel} }) {
delete $self->{factoids}->hash->{$channel}; delete $self->{factoids}->hash->{$channel};
} }

View File

@ -98,7 +98,7 @@ sub get_channels {
$nick = lc $nick; $nick = lc $nick;
foreach my $channel (keys $self->{nicklist}) { foreach my $channel (keys %{ $self->{nicklist} }) {
if (exists $self->{nicklist}->{$channel}->{$nick}) { if (exists $self->{nicklist}->{$channel}->{$nick}) {
push @channels, $channel; push @channels, $channel;
} }
@ -140,7 +140,7 @@ sub is_present_similar {
$percentage = 0.20 if not defined $percentage; $percentage = 0.20 if not defined $percentage;
my $now = gettimeofday; my $now = gettimeofday;
foreach my $person (sort { $self->{nicklist}->{$channel}->{$b}->{timestamp} <=> $self->{nicklist}->{$channel}->{$a}->{timestamp} } keys $self->{nicklist}->{$channel}) { foreach my $person (sort { $self->{nicklist}->{$channel}->{$b}->{timestamp} <=> $self->{nicklist}->{$channel}->{$a}->{timestamp} } keys %{ $self->{nicklist}->{$channel} }) {
return 0 if $now - $self->{nicklist}->{$channel}->{$person}->{timestamp} > 3600; # 1 hour return 0 if $now - $self->{nicklist}->{$channel}->{$person}->{timestamp} > 3600; # 1 hour
my $distance = fastdistance($nick, $person); my $distance = fastdistance($nick, $person);
my $length = length $nick > length $person ? length $nick : length $person; my $length = length $nick > length $person ? length $nick : length $person;
@ -165,7 +165,8 @@ sub random_nick {
if (exists $self->{nicklist}->{$channel}) { if (exists $self->{nicklist}->{$channel}) {
my $now = gettimeofday; my $now = gettimeofday;
my @nicks = grep { $now - $self->{nicklist}->{$channel}->{$_}->{timestamp} < 3600 * 2 } keys $self->{nicklist}->{$channel}; my @nicks = grep { $now - $self->{nicklist}->{$channel}->{$_}->{timestamp} < 3600 * 2 } keys %{ $self->{nicklist}->{$channel} };
my $nick = $nicks[rand @nicks]; my $nick = $nicks[rand @nicks];
return $self->{nicklist}->{$channel}->{$nick}->{nick}; return $self->{nicklist}->{$channel}->{$nick}->{nick};
} else { } else {
@ -210,7 +211,7 @@ sub on_quit {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host); my ($nick, $user, $host) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host);
foreach my $channel (keys $self->{nicklist}) { foreach my $channel (keys %{ $self->{nicklist} }) {
if ($self->is_present($channel, $nick)) { if ($self->is_present($channel, $nick)) {
$self->remove_nick($channel, $nick); $self->remove_nick($channel, $nick);
} }
@ -230,7 +231,7 @@ sub on_nickchange {
my ($self, $event_type, $event) = @_; my ($self, $event_type, $event) = @_;
my ($nick, $user, $host, $newnick) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args); my ($nick, $user, $host, $newnick) = ($event->{event}->nick, $event->{event}->user, $event->{event}->host, $event->{event}->args);
foreach my $channel (keys $self->{nicklist}) { foreach my $channel (keys %{ $self->{nicklist} }) {
if ($self->is_present($channel, $nick)) { if ($self->is_present($channel, $nick)) {
$self->remove_nick($channel, $nick); $self->remove_nick($channel, $nick);
$self->add_nick($channel, $newnick); $self->add_nick($channel, $newnick);

View File

@ -154,7 +154,7 @@ sub list_cmd {
my $count = 0; my $count = 0;
my $comma = ''; my $comma = '';
foreach my $plugin (sort keys $self->{plugins}) { foreach my $plugin (sort keys %{ $self->{plugins} }) {
$result .= $comma . $plugin; $result .= $comma . $plugin;
$count++; $count++;
$comma = ', '; $comma = ', ';

View File

@ -97,7 +97,7 @@ sub remove {
delete $self->{registry}->hash->{$section}->{$item}; delete $self->{registry}->hash->{$section}->{$item};
if(not scalar keys $self->{registry}->hash->{$section}) { if(not scalar keys %{ $self->{registry}->hash->{$section} }) {
delete $self->{registry}->hash->{$section}; delete $self->{registry}->hash->{$section};
} }