Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: How to convert an @ARGV to form based input?

by taint (Chaplain)
on Aug 21, 2012 at 07:52 UTC ( #988624=note: print w/ replies, xml ) Need Help??


in reply to Re^3: How to convert an @ARGV to form based input?
in thread How to convert an @ARGV to form based input?

Greetings @grizzley, and thank you for your reply. Sadly, following your advice DOES define $domain, but doing so only nullifies the if loop. So the form fields never show up. FWIW, the perl output in the web log reveals:

Use of uninitialized value $domain in string ne at dnsdig.cgi line 9. Use of uninitialized value $domain in concatenation (.) or string at d +nsdig.cgi line 18. Can't call method "answer" on an undefined value at dnsdig.cgi line 19 +.

If I understood you correctly, the code I used was:
#!/usr/bin/perl -w use strict; use Net::DNS; my $dns = new Net::DNS::Resolver; my $domain; 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"; } }

Thanks again for taking the time to respond.
--Chris
#!/usr/bin/perl -Tw
use perl::always;
my $perl_version = "5.12.4";
print $perl_version;


Comment on Re^4: How to convert an @ARGV to form based input?
Select or Download Code
Re^5: How to convert an @ARGV to form based input?
by taint (Chaplain) on Aug 21, 2012 at 08:03 UTC
    D'OH!
    That should have read:
    if($domain eq "") {
    not
    if($domain ne "") {
    Sorry.
    It still doesn't work.
    --Chris
    #!/usr/bin/perl -Tw
    use perl::always;
    my $perl_version = "5.12.4";
    print $perl_version;
Re^5: How to convert an @ARGV to form based input?
by grizzley (Chaplain) on Aug 21, 2012 at 08:04 UTC

    Ok, now the error message looks differently, don't you agree? :)

    $domain is already defined, but uninitialized. Please replace my $domain; with my $domain = 'google.com'; and check the result.
      Yes, I agree. :)
      Just tried this:
      #!/usr/bin/perl -w use strict; use Net::DNS; my $dns = new Net::DNS::Resolver; my $domain; if($domain ne "") { 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 { print "content-type:text/html; charset=utf-8\n\n"; print "<form action=\"dnsdig.cgi\" method=\"post\"> <input name=\"domain\" type=\"text\" value=\"\" /> <input type=\"submit\" value=\"Get MX\" /> </form>"; }
      But again, fail:
      Use of uninitialized value $domain in string ne at dnsdig.cgi line 9. Use of uninitialized value $domain in string ne at dnsdig.cgi line 9., + referer: ...
      Now I'll use your newest recommendation (which I know will work), but doesn't provide the empty form field I'm looking for -- but I'll do it anyway. :)
      --Chris
      #!/usr/bin/perl -Tw
      use perl::always;
      my $perl_version = "5.12.4";
      print $perl_version;
        Well, as you might expect, the output returned:
        google.com: alt3.aspmx.l.google.com [40 +] alt4.aspmx.l.google.com [50 +] aspmx.l.google.com [10 +] alt2.aspmx.l.google.com [30 +] alt1.aspmx.l.google.com [20 +]
        Now, if I could only figure out how to return the form field...
        changing eq "" to ne "" didn't return form fields either. :(
        Thanks again for taking the time to respond.
        --Chris
        #!/usr/bin/perl -Tw
        use perl::always;
        my $perl_version = "5.12.4";
        print $perl_version;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988624]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (17)
As of 2014-12-18 21:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (64 votes), past polls