From: Vincent Pit Date: Sat, 10 Mar 2012 18:13:55 +0000 (+0100) Subject: A cleaner idiom for "get the list of connected servers" X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=1653942ef55abd3f4aefff434f4452b641b3ce76;p=perl%2Fscripts%2Fxchat.git A cleaner idiom for "get the list of connected servers" --- diff --git a/clones.pl b/clones.pl index 5e38595..20aecfa 100755 --- a/clones.pl +++ b/clones.pl @@ -266,9 +266,9 @@ hook_server 'QUIT', sub { }; hook_print 'Disconnected', sub { - my %servers = map { $_->{server} => 1 } - grep { $_->{flags} & 9 and not($_->{flags} & 2) } - get_list 'channels'; + my %servers; + $servers{$_->{server}} = 1 for grep +($_->{flags} & 0b1011) == 0b1001, + get_list 'channels'; delete @users{ grep !$servers{$_}, keys %users}; delete @fetched{grep !$servers{$_}, keys %fetched}; diff --git a/opers.pl b/opers.pl index 875abc9..87a01c4 100755 --- a/opers.pl +++ b/opers.pl @@ -51,9 +51,9 @@ hook_server '352', sub { }; hook_print 'Disconnected', sub { - my %servers = map { $_->{server} => 1 } - grep { $_->{flags} & 9 and not($_->{flags} & 2) } - get_list 'channels'; + my %servers; + $servers{$_->{server}} = 1 for grep +($_->{flags} & 0b1011) == 0b1001, + get_list 'channels'; delete @opers{grep !$servers{$_}, keys %opers};