#***************************************************************************** #* _ _ ____ _ #* Project ___| | | | _ \| | #* / __| | | | |_) | | #* | (__| |_| | _ <| |___ #* \___|\___/|_| \_\_____| #* #* $Id: perl_interface.pl,v 1.0 2007/08/10 13:45:11 Voldor Exp $ #***************************************************************************** #!/usr/bin/perl -w #perl -MInline=Force,NoClean,Info perl_interface.pl // Debugging #perl perl_interface.pl // Run it #pp -M FindBin -M Inline -o perl_interface.pl perl_interface => #Compile stand-alone exe, remember _Inline dir - not use comments or ___EOF___ use Inline C => Config => ENABLE => AUTOWRAP => #Use curl functions AUTO_INCLUDE => '#include "curl/curl.h"' => #Curl library LIBS => "-lcurl"; #Curl flag use Inline C => <<'END'; char* curl_inline(char* host) { CURL *curl; CURLcode res; curl = curl_easy_init(); curl_easy_setopt(curl, CURLOPT_URL, host); curl_easy_setopt(curl, CURLOPT_HEADER, 1); curl_easy_setopt(curl, CURLOPT_FAILONERROR, 1); curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); res = curl_easy_perform(curl); curl_easy_cleanup(curl); } END if (@ARGV < 1) { print("Usage: $0 \n"); print("Example: ./$0 www.google.com\n"); exit(1); } my $host = shift; #Take input curl_inline($host); #Run c code