Subject: | Adding an options method to a Net::Server subclass breaks the port option |
Consider the following code:
#!/usr/bin/perl
package Example;
use base(Net::Server);
sub options {}
Example->run(port => 123456);
#end
This, when run, doesn't bind to port 123456, but instead to the default
port of 20203. Removing the empty options method fixes the issue.
I'll admit to not full understanding the way options are supposed to be
extended, so perhaps this is expected behavior. If I handle port in the
options method it seems to work correctly.
#!/usr/bin/perl
package Example;
use base(Net::Server);
sub options {
my $self = shift;
my $prop = $self->{'server'};
my $template = shift;
#add the port option
$prop->{'port'} ||= undef;
$template->{'port'} = \ $prop->{'port'};
}
Example->run(port => 123456);
#end