Connecting Tech Pros Worldwide Forums | Help | Site Map

problem with code conversion from php to perl

Newbie
 
Join Date: Jan 2007
Posts: 1
#1: Jan 18 '07
i am trying to convert a code of php to perl


in php we use $_cookie[cookiename] to retrieve cookie value


i have to do the same in perl


i have got the cookie some how , but i dont know how to access its value , i tried 3 days banging my head but in vain


second i want to open a URL with the socket im using this code


sub plFetchAlertValue($)
{

my ($userId) = @_;

use IO::Socket;




my $query = "http://dev.iventster.com/pl/publisherCmd.php?cmd=hasAlert&userId=$userId";

my @url = split(/.com/, $query);

my $host="$url[0].com";

my $path=$url[1];

my $timeout = 5;






my $sock = new IO::Socket::INET (LocalHost =>$host,LocalPort =>80,Proto => 'TCP',Timeout =>$timeout);

die "couldnt connect $!" unless $sock;



but it give the message

(couldnt connect Address already in use) i tried the ip address in $host as 192.168.1.100 and 127.0.0.1 too ,but the same result


would some one guide me to this prblms

KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#2: Jan 18 '07

re: problem with code conversion from php to perl


as far as the cookie goes:

http://perldoc.perl.org/CGI/Cookie.html

or if you are already doing some CGI stuff you may want to use the CGI module to do all the CGI stuff:

http://perldoc.perl.org/CGI.html
KevinADC's Avatar
Expert
 
Join Date: Jan 2007
Location: Southern California USA
Posts: 4,091
#3: Jan 18 '07

re: problem with code conversion from php to perl


as for the rest your question, all I can suggest is you read the corresponding documentation for the module(s):

http://perldoc.perl.org/index-modules-I.html

but it does look like you have loaded the IO::Socket module but try and create a new object of the IO::Socket::INET class. But read the docs, I have little experience with those modules.
Reply