Perl并发症在“has ... => ...”上失败了

时间:2018-05-22 06:23:46

标签: perl mojolicious

有没有人可以在下面的cgi.pm中帮助解释关于“有使用情况......”,“有说明......”的语法吗?

package Mojolicious::Command::cgi;
use Mojo::Base 'Mojolicious::Command';

use Mojo::Server::CGI;
use Mojo::Util 'getopt';

has description => 'Start application with CGI';
has usage => sub { shift->extract_usage };

sub run {
  my ($self, @args) = @_;
  getopt \@args, nph => \(my $nph = 0);
  Mojo::Server::CGI->new(app => $self->app, nph => $nph)->run;
}

1;

1 个答案:

答案 0 :(得分:0)

请参阅Mojo::Base documentationhas函数定义了类的属性。

在这种情况下,Mojo::Command::cgi具有Mojolicious::Command基类,description属性默认为提供的字符串,usage属性将通过调用{{来初始化1}}方法。