* [PATCH] nntp: simplify method detection using UNIVERSAL::can
@ 2019-12-22 0:12 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2019-12-22 0:12 UTC (permalink / raw)
To: meta
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 3d3ad539..65c0519a 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);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-22 0:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-22 0:12 [PATCH] nntp: simplify method detection using UNIVERSAL::can Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).