I need some help understanding the following Perl code snippet. I have the following two questions.
1.
What does local *PIPER mean? Even though I've done some Perl programming before the local * syntax is new to me. Is it a pointer?
2. What is the purpose of
curl http://www.somesite.net/cgi-bin/updateuser.cgi? -d "userid=$userid&password=$password\" -s |"; ?
Thank You :)
local *PIPER;
$http_query = "curl http://www.somesite.net/cgi-bin/updateuser.cgi? -d \"userid=$userid&password=$password\" -s |";
open(PIPER,$http_query) or die "sorry";
while(<PIPER>)
{
$rets = $_;
}
close(PIPER);
return $rets;
1) "
*PIPER" is a typeglob. It is "$PIPER", "@PIPER", and "%PIPER" (and I then some) all in one. They are declaring all*PIPERnames local to the code snippet you have.2) That's a shell command. It ends with a
|which means that that command is being run, and it's output is being piped in as the input for the filehandlePIPER. The program then reads this line-by-line withwhile(<PIPER>), but you already know that.I don't know much about
curl, but I know it's a command-line program for doing stuff on the internet. Just a random stab, your code appears to be accessing a website's CGI script and sending it some information.