root/apps/perl/trunk/lookup/recurse.pl
| Revision 318, 0.9 kB (checked in by henri, 4 years ago) | |
|---|---|
|
|
| Line | |
|---|---|
| 1 | # sample script that recurses through Non-Terminal NAPTR records |
| 2 | # Author: Henri Asseily < henri.tel > |
| 3 | |
| 4 | use lib 'lib'; # uses a locally modified version of Net::Lookup::DotTel 0.1 |
| 5 | use Net::Lookup::DotTel; |
| 6 | |
| 7 | our $maxdepth = 5; # don't go deeper than this in subdomains |
| 8 | our $currdepth = 0; |
| 9 | |
| 10 | sub lookmeup { |
| 11 | $currdepth++; |
| 12 | return if ($currdepth >= $maxdepth); |
| 13 | my $domain = shift || return; |
| 14 | warn "Entering domain: $domain\n"; |
| 15 | my $lookup = Net::Lookup::DotTel->new; |
| 16 | |
| 17 | if ( $lookup->lookup ( $domain )) { |
| 18 | my @s = $lookup->get_services; |
| 19 | foreach my $s (@s) { |
| 20 | if ($s->{flags} eq '') { # non-terminal, recurse down |
| 21 | &lookmeup($s->{replacement}); |
| 22 | } else { |
| 23 | # Here we've got terminal records |
| 24 | if ( $s->{uri} =~ /^mailto:(.+)/ ) { |
| 25 | my $email = $1; |
| 26 | warn "Found email: $email\n"; |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | } |
| 31 | $currdepth--; |
| 32 | } # sub lookmeup |
| 33 | |
| 34 | my $d = shift || die "Usage: $0 domain.tel\n"; |
| 35 | &lookmeup($d); |
Note: See TracBrowser
for help on using the browser.








