in reply to How to convert an @ARGV to form based input?
You have explained a bit about what you don't want but you haven't said much about what you do want, so I can only guess. Anyway, you seem to be having a problem accessing CGI parameters from your script. Here is one simple way to access a CGI parameter:
use strict; use warnings; use Net::DNS; use CGI; use CGI::Carp qw{fatalsToBrowser}; my $q = CGI->new(); my $dns = new Net::DNS::Resolver; if(my $domain = $q->param('domain')) { my $mx = $dns->query( $domain, 'MX' ); print "content-type:text/html; charset=utf-8\n\n"; print "$domain:\n\n"; foreach my $rr ($mx->answer) { print "<br />", $rr->exchange, ' [<b>', $rr->preference, "</b> +]\n"; } } else { die "missing required parameter: domain"; }
If you query this CGI script with a URL like:
http://mydomain.tld/dnsdig.cgi?domain=google.com
You should get something.
It is unusual, in my experience, to use unnamed parameters with HTTP requests. Whether using GET or POST, I always name my parameters. Note that this CGI script will work with both GET requests, with parameters in the URL or POST requests with parameters in the body, as commony submitted from HTML forms.
Hopefully, this will get you past your block, to see how query parameters can be accessed from within a CGI script.
Do read up on CGI and CGI::Carp
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to convert an @ARGV to form based input?
by Anonymous Monk on Aug 21, 2012 at 08:36 UTC | |
Re^2: How to convert an @ARGV to form based input?
by taint (Chaplain) on Aug 21, 2012 at 08:57 UTC | |
by Anonymous Monk on Aug 21, 2012 at 09:00 UTC | |
by taint (Chaplain) on Aug 21, 2012 at 09:10 UTC | |
by aaron_baugher (Curate) on Aug 21, 2012 at 09:55 UTC | |
by Anonymous Monk on Aug 21, 2012 at 09:39 UTC | |
by ig (Vicar) on Aug 21, 2012 at 14:02 UTC |