How do I write a Perl script to use curl to process a URL?

折月煮酒 提交于 2019-12-12 08:26:38

问题


I have a very simple task. I have a crontab that will run a script every hour. The script is meant to simply process a URL.

This is what I have. It doesn't work. I get a syntax error.

#!/usr/bin/perl
curl http://domain.com/page.html;

I haven't worked in Perl in years and wasn't very adept when I did.

SOLUTION

Thanks, Alex for pointing me to the correct path!

crontab

*/30 * * * * curl http://domain.com/path.html

回答1:


You can either use curl via backticks

my $curl=`curl http://whatever`

or you can use WWW::Curl.




回答2:


To call any shell command from Perl, you can use system:

system "curl http://domain.com/page.html";

Just enclose the shell command in quotes.



来源:https://stackoverflow.com/questions/7196124/how-do-i-write-a-perl-script-to-use-curl-to-process-a-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!