How to write a Perl script to use curl to handle URLs?

I have a very simple task. I have a crontab that will run a script every hour. The script is for simple URL handling.

This is what I have. This does not work. I get a syntax error.

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

I have not worked in Perl for many years and was not very skilled when I did it.

Decision

Thanks Alex for pointing the right way!

crontab

 */30 * * * * curl http://domain.com/path.html 
+8
perl curl cron crontab
source share
2 answers

You can use curl via return outputs

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

or you can use WWW::Curl .

+23
source share

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

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

Just enclose the shell command in quotation marks.

+5
source share

All Articles