From f1f0db6ba1118ee91eaf93bc1e1805fecdb16948 Mon Sep 17 00:00:00 2001
From: Eric Wong <e@80x24.org>
Date: Sun, 22 Dec 2019 00:12:45 +0000
Subject: [PATCH] nntp: simplify method detection using UNIVERSAL::can

No need to do an eval dance or disable strict refs.
---
 lib/PublicInbox/NNTP.pm | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 6cd2b84c..5c23e476 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -81,10 +81,7 @@ sub process_line ($$) {
 	my ($self, $l) = @_;
 	my ($req, @args) = split(/[ \t]/, $l);
 	return 1 unless defined($req); # skip blank line
-	$req = eval {
-		no strict 'refs';
-		*{'cmd_'.lc($req)}{CODE};
-	};
+	$req = $self->can('cmd_'.lc($req));
 	return res($self, '500 command not recognized') unless $req;
 	return res($self, r501) unless args_ok($req, scalar @args);
 
@@ -173,11 +170,7 @@ sub cmd_list ($;$$) {
 		my $arg = shift @args;
 		$arg =~ tr/A-Z./a-z_/;
 		$arg = "list_$arg";
-
-		$arg = eval {
-			no strict 'refs';
-			*{$arg}{CODE};
-		};
+		$arg = $self->can($arg);
 		return r501 unless $arg && args_ok($arg, scalar @args);
 		more($self, '215 information follows');
 		$arg->($self, @args);
-- 
2.50.0