Fix or Rewrite Perl Script

Fix or Rewrite Perl Script

Closed - This job posting has been filled and work has been completed.

Job Description

#!/usr/bin/perl

$url = "http://www.zenlyzen.com/test1";
$msg = "test%20message";
$email = "a@a.com";
$name = "foo%20bar";

sub sndmsg {
@mdump = `mech-dump --forms '$url/index.php?main_page=contact_us'`;
foreach $line (@mdump) {
if ($line =~ /POST/) {
print "$line";
$line =~ /zenid=(\w+)/;
$zenid = $1;
}
if ($line =~ /securityToken/) {
$line =~ /securityToken=(\w+)/;
$sectoc = $1;
}
}
# print "curl -A \"Mozilla/5.0\" -L -b securityToken=$sectoc -s -d \"contactname=$_[3]&mail=$_[2]&enquiry=$_[1]\" $_[0]/index.php?main_page=contact_us\\&action=send%20method=\"post\" > test.html\n";
system "curl -A \"Mozilla/5.0\" -L -b securityToken=$sectoc -s -d \"contactname=$_[3]&mail=$_[2]&enquiry=$_[1]\" $_[0]/index.php?main_page=contact_us\\&action=send%20method=\"post\" > test.html";

}
sndmsg($url, $msg, $email, $name);
exit;

I hope this will be pretty much self explanatory. You may use strict and warn but this is not required. I do not want perl modules used, stick to the backticks and system commands. I don't care if you end up using curl, wget, mech-dump, or other GPL software. Avoid long and convoluted patterns. Break them up and document them with comments. Same thing for if statements. The sndmsg subroutine is supposed to post the appropriate data to the form. $url is the base url for the site. I have three more test sites set up for testing.

---
Skills: test