Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Pulling Data From A Command Line

by lisaw (Beadle)
on Oct 15, 2002 at 15:55 UTC ( [id://205408]=perlquestion: print w/replies, xml ) Need Help??

lisaw has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I was hoping that you good people could help me. I am trying to figure out how to take data from a address line and insert it into a cgi program
http://www.domain.com/bin/sendnotice.cgi?category=ArtsArt&email=me@me. +com&password=369728 Data trying to transfer into cgi: catgory email password
Here's the program that I'm trying to transfer the data into, and the part that I can't figure out:
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\n/ /g; $request{$name} = $value; } $url = "http://www.domain.com"; $refer = "http://www.domain.com"; $maillocation = "/usr/sbin/sendmail"; $stmail="$request{'category'}" ; $tmail="$request{'email'}" ; $tnmail="$request{'password'}" ;
Any help would be greatly apprecieted. Lisa

Replies are listed 'Best First'.
Re: Pulling Data From A Command Line
by zigdon (Deacon) on Oct 15, 2002 at 16:00 UTC

    Hate to give you the party line, but any reason why not to use CGI?:

    use CGI; use strict; use warnings; my $q = new CGI; my $url = $q->url(-base); my $refer = $ENV{HTTP_REFERER}; my $maillocation = "/usr/sbin/sendmail"; my $stmail=$q->param('category'); my $tmail=$q->param('email'); my $tnmail=$q->param('password');

    Update: Aristotle is defenitly right, added strict, warnings and a bunch of my's.

    -- Dan

      Hate to give you the party line, but where's strict and warnings? ;-) Also, consider using the referer() method.
      #!/usr/bin/perl -w use strict; use CGI; my $q = new CGI; my ($url, $ref, $sendmail) = ( $q->url(-base), $q->referer, "/usr/sbin/sendmail", ); # can't use list assingnment here because param() # may return more than one value my ($stmail, $tmail, $tnmail); $stmail=$q->param('category'); $tmail=$q->param('email'); $tnmail=$q->param('password');

      Makeshifts last the longest.

Re: Pulling Data From A Command Line
by rdfield (Priest) on Oct 15, 2002 at 15:59 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://205408]
Approved by broquaint
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-26 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found