Help with PERL forms

How would I go about programming a PERL script that submits
a form and mails it to me?

I would like a working script (if possible).  I am going to write my own, but it would be helpful to have a script (described step-by-step) that I can use as a reference.  

Thanks,

Ace~
LVL 1
TopaceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sanekCommented:
Submits using GET method.
#!/usr/local/bin/perl5 -w

# use helpful pm's
use LWP::Simple;
use URI::URL;

my $url = url('http://some.website.com/cgi-bin/some.cgi');
$url->query_form(
param_no_1 => "param1",
param_no_2 => "param2"
);

$content = get($url);

# now mail the content to you.
open( SENDMAIL, '| /usr/sbin/sendmail -oi -n -t') || die "Cannot open sendmail!";
print SENDMAIL <<MESSAGE;
From: script\@domain.com
To: your_mail\@domain.com
Subject: submitted form

$content
MESSAGE

close (SENDMAIL);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TopaceAuthor Commented:
Hmmm... this looks good, but could you explain it a little for me?  I'm kinda a rookie at PERL Programming on the Web.  

Thanks,
Ace~
0
ozoCommented:
What do you wish to have explained?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

sanekCommented:
my $url = url('http://some.website.com/cgi-bin/some.cgi');
$url->query_form(
      param_no_1 => "param1",
      param_no_2 => "param2"
      );
$content = get($url);

These lines retreive content outputted by CGI $url.

Next lines use sendmail program to send you $content.
We have to construct mail body (to specify To, From, Subject and body fields).

Anything in particular you want to ask?
0
TopaceAuthor Commented:
So, does
$url->query_form(
                param_no_1 => "param1",
                param_no_2 => "param2"

just parse the information gotten from the script?  

open( SENDMAIL, '| /usr/sbin/sendmail -oi -n -t')
This line opens SENDMAIL, what do the -oi -n -t extensions do?

finally...
if sendmail is the filehandle opened, what is
print SENDMAIL <<MESSAGE; ?

Is MESSAGE the message from the form?

Also -- what if my server doesn't support SENDMAIL? I am not sure, but I will find out.  

Ace~
0
sanekCommented:
$url->query_form(
                     param_no_1 => "param1",
                     param_no_2 => "param2" );
does not PARSE information, it's just SETS fields in request to
CGI.

I'm not sure what switches -oi -n -t  do, I've just took it from
working script. You can find about senmail by 'man sendmail'.

$a = 4;
print <<SOME_LABEL; # Variation of Perl command
Text will be printed, until SOME_LABEL label is reached.
Varibales will be evaluated \$a=$a;
SOME_LABEL

Thus, "print SENDMAIL <<MESSAGE; "
just prints following it text to sendmail.
0
TopaceAuthor Commented:
Thank you, I believe I can figure out what I want to do from here.

Ace~
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.