Greetings, Well, I spent last weekend creating an all encompassing DNS query perl script. Creation & testing was done from the CLI. Everything worked as intended. So today I set out to convert it to a web based form. But apparently my train of thought decoupled a few cars somewhere along the line. Because no matter how hard I tried, I couldn't generate a form that either 1) posted the input variable, or 2) didn't make perl squeal bloody murder. WHat I had hoped to accomplish today, was to incorporate a form field inline (within the script itself), using the POST method (to help thwart users embedding a query string from within their own pages, against mine). The script is quite large, but here's a snippet, that should reveal my intent:
#!/usr/bin/perl -w use strict; use Net::DNS; my $dns = new Net::DNS::Resolver; for my $domain( @ARGV ) { 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"; } }
using the above in a web page as:
http://mydomain.tld/dnsdig.cgi?google.com
produces the intended output. But, any incarnation of:
# replace for my $domain( @ARGV ) { # with if($domain ne "") { print "<form action=\"dnsdig.cgi\" method=\"post\"> <input name=\"domain\" type=\"text\" value=\"\" /> <input type=\"submit\" value=\"Get MX\" /> </form>"; } else { 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"; } }
fails! :(
YES. I know $domain is replaced with (@ARGV), and this is truly trivial, but for the life of me, I'm stuck. Please help.
Thank you for all of your time and consideration.
--Chris
#!/usr/bin/perl -Tw
use perl::always;
my $perl_version = "5.12.4";
print $perl_version;

In reply to How to convert an @ARGV to form based input? by taint

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.