ionstorm101
Programmer
Ok, this program im writing is part of a challenge on a site. Basically I have to connect to a page, take the output, parse out a string, append that string to a url and then connect to that url to get the solution. The following is my code
The parsing of the string etc works fine but when i go to run it i get this error
For the life of me I cant see whats wrong although im sure its only something basic.
By the way, could someone also tell me what the form of recv() is when you are using IO::Socket. I know the normal recv() when you are just using Socket is recv(Socket_Handle, buffer) but what should i put in for the socket handle here?
Any help is appreciated, thanks,
ionstorm.
Code:
#!usr/bin/env perl -w
use IO::Socket;
$sock = new IO::Socket::INET(PeerAddr => '[URL unfurl="true"]http://www.bright-shadows.net/challenges/programming/get_started/tryout.php',[/URL]
PeerPort => 80,
Proto => 'tcp');
die "Error opening socket/connecting: $!" unless $sock;
$buffer = <$sock>;
$buffer =~ /'+(.+)'+/;
$solution = "[URL unfurl="true"]http://www.bright-shadows.net/challenges/programming/get_started/solution.php?solution=";[/URL]
$solution .= $1;
$new_sock = new IO::Socket::INET(PeerAddr => $solution,
PeerPort => 80,
Proto => 'tcp');
die "Error opening socket/connecting: $!" unless $new_sock;
while($new_sock){
print "$_";
}
close($sock);
Code:
[nnp@localhost perl]$ perl connect.pl
Error opening socket/connecting: Invalid argument at connect.pl line 10.
By the way, could someone also tell me what the form of recv() is when you are using IO::Socket. I know the normal recv() when you are just using Socket is recv(Socket_Handle, buffer) but what should i put in for the socket handle here?
Any help is appreciated, thanks,
ionstorm.