ojo-Mojo趣味单线
$perl-Mojo-E'说g(“mojolicious.org”)->dom->at(“title”)->文本'
一组用于有趣的Perl单行程序的自动导出函数。默认情况下将遵循十个重定向,您可以使用MOJO_MAX_编辑
环境变量。
$MOJO_MAX_REDIRECTS=0 perl-MOJO-E'说g(“example.com”)->代码'
默认情况下启用代理检测,但您可以使用MOJO_代理
环境变量。
$MOJO_PROXY=0 perl-MOJO-E'说g(“example.com”)->body'
可以使用禁用TLS证书验证MOJO_保险
环境变量。
$MOJO_INSECURE=1 perl-MOJO-E'说g(“https://127.0.0.1:3000“)->车身'
每ojo公司单衬里也是一种Mojolicious::精简应用程序。
$perl-Mojo-E'get“/”=>{inline=>“%=time”};应用程序->开始'获取/
在Perl 5.20上+子程序签名将自动启用。
$perl-Mojo-E'a(sub($c){$c->render(text=>“Hello!”)})->start'get/
如果尚未定义,则MOJO_LOG_LEVEL(MOJO_日志_级别)
环境变量将设置为致命的
.
ojo公司实现以下自动导出的功能。
我的$app=a('/hello'=>sub{$_->render(json=>{hello=>'world'})});
使用创建路线Mojolicous::Lite中的“任意”并返回电流Mojolicious::精简对象。当前控制器对象也可用于以下操作$_
。另请参阅Mojolicuis::指南::教程了解更多参数变化。
$perl-Mojo-E'a(“/hello”=>{text=>“hello Mojo!”})->start'守护进程
我的$stream=b('lalala');
将字符串转换为Mojo::ByteStream对象。
$perl-Mojo-E'b(g(“mojolicious.org”)->body)->html_unescape->say'
我的$集合=c(1,2,3);
将列表转换为Mojo::系列对象。
my$res=d('example.com');我的$res=d('http://example.com'=>{Accept=>'*/*'}=>'Hi!');我的$res=d('http://example.com'=>{Accept=>'*/*'}=>form=>{a=>'b'});我的$res=d('http://example.com'=>{Accept=>'*/*'}=>json=>{a=>'b'});
执行删除
请求Mojo::UserAgent中的“删除”并返回结果Mojo::消息::响应对象。
my$path=f('/home/sri/foo.txt');
将字符串转换为Mojo::文件对象。
$perl-Mojo-E'说rjf(“hello.json”)->slurp'
my$res=g('example.com');我的$res=g('http://example.com'=>{Accept=>'*/*'}=>'Hi!');我的$res=g('http://example.com'=>{Accept=>'*/*'}=>form=>{a=>'b'});我的$res=g('http://example.com'=>{Accept=>'*/*'}=>json=>{a=>'b'});
执行GET(获取)
请求Mojo::UserAgent中的“get”并返回结果Mojo::消息::响应对象。
$perl-Mojo-E'说g(“mojolicious.org”)->dom(“h1”)->map(“text”)->join(“\n”)'
my$res=h('example.com');我的$res=h('http://example.com'=>{Accept=>'*/*'}=>'Hi!');我的$res=h('http://example.com'=>{Accept=>'*/*'}=>form=>{a=>'b'});我的$res=h('http://example.com'=>{Accept=>'*/*'}=>json=>{a=>'b'});
执行头部
请求Mojo::UserAgent中的“head”并返回结果Mojo::消息::响应对象。
我的$字节=j([1,2,3]);我的$bytes=j({foo=>'bar'});我的$value=j($bytes);
使用编码Perl数据结构或解码JSONMojo::JSON中的“j”.
$perl-Mojo-E'f(“hello.json”)->pupt(j{hello=>“世界!”})'
我的$url=l('https://mojolicious.org');
将字符串转换为Mojo::URL对象。
$perl-Mojo-E'说l(“/perldoc”)->to_abs(l(“https://mojolicious.org"))'
n{…};n{…}100;
基准块并将结果打印到STDERR公司
,迭代次数可选,默认为1
.
$perl-Mojo-E'n{say g(“mojolicious.org”)->代码}'
my$res=o('example.com');我的$res=o('http://example.com'=>{Accept=>'*/*'}=>“嗨!”);我的$res=o('http://example.com'=>{Accept=>'*/*'}=>form=>{a=>'b'});我的$res=o('http://example.com'=>{Accept=>'*/*'}=>json=>{a=>'b'});
执行选项
请求Mojo::UserAgent中的“选项”并返回结果Mojo::消息::响应对象。
my$res=p('example.com');我的$res=p('http://example.com'=>{Accept=>'*/*'}=>'Hi!');我的$res=p('http://example.com'=>{Accept=>'*/*'}=>form=>{a=>'b'});我的$res=p('http://example.com'=>{Accept=>'*/*'}=>json=>{a=>'b'});
执行邮政
请求Mojo::UserAgent中的“帖子”并返回结果Mojo::消息::响应对象。
我的$perl=r({data=>“结构”});
使用转储Perl数据结构Mojo中的“翻车机”:Util.
perl-Mojo-E'说rg(“example.com”)->headers->to_hash'
my$res=t('example.com');我的$res=t('http://example.com'=>{Accept=>'*/*'}=>'Hi!');我的$res=t('http://example.com'=>{Accept=>'*/*'}=>form=>{a=>'b'});我的$res=t('http://example.com'=>{Accept=>'*/*'}=>json=>{a=>'b'});
执行补丁
请求Mojo::UserAgent中的“补丁”并返回结果Mojo::消息::响应对象。
my$res=u('example.com');我的$res=u('http://example.com'=>{Accept=>'*/*'}=>'Hi!');我的$res=u('http://example.com'=>{Accept=>'*/*'}=>form=>{a=>'b'});我的$res=u('http://example.com'=>{Accept=>'*/*'}=>json=>{a=>'b'});
执行PUT(输出)
请求Mojo::UserAgent中的“put”并返回结果Mojo::消息::响应对象。
my$dom=x('<div>你好!</div>');
将HTML/XML输入转换为Mojo::DOM对象。
$perl-Mojo-E'说x(f(“test.html”)->slurp)->at(“title”)->文本'
Mojolicious公司,Mojolicious::指南,https://mojolicious.org.