莫约利奇如何修改perl语法
阅读mojolicious minions文档我找到了以下代码:
use v5.28;
use Mojolicious::Lite;
use experimental qw( signatures );
use Time::HiRes qw( time );
plugin Minion => {
SQLite => 'sqlite:' . app->home->child('minion.db'),
};
# ...
app->start;
如何 找到以下代码:他们是否创建了一个新的语法插件minion => {...}
?我从未在经典的佩尔书中见过。它是带有哈希参数的函数调用:“小牛仔”是钥匙,而hashref {...}
是一个值?
他们还调用app-> start
- app
是返回祝福的hashref的功能吗?但是,如果这是一个哈希,为什么“开始”不会封闭在牙套中?这个语法对我来说很奇怪。
Reading Mojolicious minions documentation I found the following code:
use v5.28;
use Mojolicious::Lite;
use experimental qw( signatures );
use Time::HiRes qw( time );
plugin Minion => {
SQLite => 'sqlite:' . app->home->child('minion.db'),
};
# ...
app->start;
How did they create a new syntax plugin Minion => {...}
? I've never seen it in classic Perl books. Is it a function call with a hash parameter: "Minion" being a key and a hashref {...}
is a value?
Also they call app->start
- app
is a function returning a blessed hashref? But if it was a hash why "start" is not enclosed into braces? This syntax looks strange to me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
app
是返回$ app
的函数,它是mojolicious :: lite = lite = hash
app-> start is same as
app()->start
https://github.com/mojolicious/mojo/blob/24d1d1987dbfbe27eaaa37dd5db692d2deb8d07f/lib/Mojolicious/Plugin/Config.pm#L12-L14
Reproduction
output
plugin< /code>是一个常规功能,
您可以添加parens,然后将fat Comma放置为通常的功能调用,
app
is a function which returns$app
which is an instance ofMojolicious::Lite=HASH
app->start
is same asapp()->start
https://github.com/mojolicious/mojo/blob/24d1d1987dbfbe27eaaa37dd5db692d2deb8d07f/lib/Mojolicious/Plugin/Config.pm#L12-L14
Reproduction
output
plugin
is a regular functionYou can add parens, and drop fat comma to look like the usual function call,