yes, you're right. both $cmd and @args will be received through the socket. hmm... what about this one:
#!/usr/bin/perl -w
{
package Net::SMTP::Server::Client2::Subclass;
use strict;
use vars qw/@ISA/;
use Net::SMTP::Server::Client2;
@ISA = qw/Net::SMTP::Server::Client2/;
my %_pcmds = ( HELO => \do { print STDERR "hello\n" }
);
our $eval_command = sub {
my ($self, $cmd, @args) = @_;
my $hash = (__PACKAGE__ =~ /Subclass$/) ? '$_pcmds' : '$
+_cmds';
$cmd = "&{$hash"."{$cmd}}(\$self, \\\@args)";
eval $cmd or return(defined($self->{MSG}));
};
&Net::SMTP::Server::Client2::eval_command = \$eval_command;
sub new {
my ($class, $sock) = @_;
my $self = $class->SUPER::new($sock);
bless $self, __PACKAGE__;
}
sub get_message {
my $self = shift;
my ($cmd, @args);
# [...}
# do everything the super class does, up to this point:
if (exists $_pcmds{$cmd}) {
$eval_command->($self, $cmd, @args);
}
else {
$self->SUPER::eval_command($cmd, @args);
}
}
1;
}
i've never done that before, but at least the compiler doesn't complain.
--------------------------------
masses are the opiate for religion.
|