Convert to PHP?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pointzero
    New Member
    • Mar 2008
    • 2

    Convert to PHP?

    Can someone help me to convert the following perl code into php? Leave the Net::DNS, Net::DNS::Resol ver, search functions as is. I can replace them with PEAR Net_DNS module.

    [code=perl]
    use Net::DNS;
    sub ablookup {
    my ($domain) = @_;
    my ($res, $query, @r);

    $res = new Net::DNS::Resol ver;
    while(1) {
    $query = $res->search("$domai n.contacts.abus e.net", "TXT");
    if ($query) {
    my $rr;

    foreach $rr ($query->answer) {
    push @r, $rr->txtdata if $rr->type eq "TXT";
    }
    return @r;
    } else { # Net::DNS rejects special characters, strip off
    # subdomains and see if a parent domain works
    if($domain =~ m{^[^.]+\.([^.]+\..+)}) {
    $domain = $1;
    } else {
    die "Cannot lookup contacts for $domain";
    }
    }
    }
    }
    [/code]

    Thanks,
    Last edited by numberwhun; Mar 10 '08, 08:26 PM. Reason: add code tags
  • numberwhun
    Recognized Expert Moderator Specialist
    • May 2007
    • 3467

    #2
    You do realize that you are asking a Perl forum to help you to convert you Perl script to PHP, don't you? I know I do not know PHP so anything I produced wouldn't work for you as it would be in Perl!

    My suggestion is that next time, you please post this question to the PHP forum, where I will now move it to.

    Also, then next time you post code in the forums, please place the necessary and proper code tags around the code. This time I will take care of it for you.

    Regards,

    Moderator

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Unfortunately i have experience in perl, so im of no assistance!

      Goood luck tho :)

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        Neither am I, and although some code looks familiar, it might help if you tell us exactly what each line does, then we could give it a fair crack. Do you know php?

        Comment

        • pointzero
          New Member
          • Mar 2008
          • 2

          #5
          My level of php is @ beginer. So... I got the code from abuse.net.

          If some help me be crack the following line, I may be able to convert the function into php.

          if($domain =~ m{^[^.]+\.([^.]+\..+)})

          Thanks

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Originally posted by pointzero
            My level of php is @ beginer. So... I got the code from abuse.net.

            If some help me be crack the following line, I may be able to convert the function into php.

            if($domain =~ m{^[^.]+\.([^.]+\..+)})

            Thanks
            What is that line trying to do?

            Comment

            Working...