I've been away from the game awhile writing some crapy policies and what not, so I'm a bit rusty. I need help with a script that I use to lookup email addresses via whois. The people at APNIC are quite upset at me. When a whois query is performed for an ip such as: 202.60.248.84 this is what is returned:

inetnum 202.60.224.0 - 202.60.251.255 netname CYBEREC-HK descr Cyber Express Communication Ltd. descr Internet Services Provider descr Broadband Internet Access Service country HK admin-c PC2-AP, inverse tech-c PC2-AP, inverse mnt-by APNIC-HM, inverse mnt-lower MAINT-HK-CYBEREC, inverse changed hostmaster@apnic.net 20000405 source APNIC person Peter Chow, inverse address Cyber Express Communication Ltd. address Room 3, 7/F, Perfect Ind. Building address 31 Tai Yau Street, Sanpokong, Kowloon country HK phone +852-2353-1445 fax-no +852-2353-1105 e-mail hkptc@cyberec.com, inverse nic-hdl PC2-AP, inverse mnt-by MAINT-HK-CYBEREC, inverse changed hkptc@cyberec.com 20000407 source APNIC

My script captures the first email address, which works about 90% of the time, but I don't want it to caputer hostmaster@apnic.net, but rather the second one. I would like to have a list of email addresses in an array that are ignorned, but I'm not quite sure how to do it. It would also be nice if I could capute the second email instead. I was messing around with last and next, but I don't believe these will work because this is not a while loop.

Here is the script:
#!/usr/bin/perl -w use strict; my $arin="/usr/bin/whois -h whois.arin.net"; my $ripe="/usr/bin/whois -h whois.ripe.net"; my $apnic="/usr/bin/whois -h whois.apnic.net"; my $krnic="/usr/bin/whois -h whois.krnic.net"; my $email; my $domain; my $result; my $ips = "203.197.64.42"; whois($ips); sub whois{ my $ip = $_[0]; $result = `$arin $ip`; if ($result =~ m/European Regional Internet Registry/){ $result = `$ripe $ip`; if (match()){ } #close if match } #close if result elsif ($result =~ m/Asia Pacific Network Information Center/){ $result = `$apnic $ip`; if ($result =~ m/hostmaster\@apnic.net/){ last; }#end if if ($result =~ m/Allocated to KRNIC Member/){ $result = `$krnic $ip`; } #end KRNIC match if (match()){ } #end if match } #end elsif elsif (handles($arin)){ if (match()) { } #end if match } #end elsif elsif (($email, $domain) = $result =~ m/([-.\w]+)(\@[-.\w]+)/) { print "The 1st email address is: $email$domain\n"; print "Email will also be sent to: abuse$domain\n"; } #end elsif else { print "Can not perform a whois query for $ip\n;" } #end else } #close whois sub ############### # Subroutines # ############### # whois: Obtain an email address from a whois query # sub match { ($email, $domain) = $result =~ m/([-.\w]+)(\@[-.\w]+)/; print "The 1st email address is: $email$domain\n"; print "Email will also be sent to: abuse$domain\n"; } #end sub match # handles: Obtain the handles from a whois query # sub handles { my $registry = $_[0]; $result =~ m/xxx/; my @handle = $result =~ m/\((.*?)\)/g; $result = `$registry $handle[1]`; } #end handles

I know the regex to capture the email address is not going to work 100% of the time, but it hasn't failed me yet.

TIA

-Dru

In reply to How to Ignore an email address with this script. by dru145

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.