Oh Great Ones,

I'm trying to extract the network handle from a whois query. Here is the results of doing a whois query with the ip of 216.68.40.234:
[whois.arin.net] Fuse Internet Access (NETBLK-FUSE-NET-BLK-1) FUSE-NET-BLK-1 216.68.0.0 - 216.68 +.255.255 Fuse Modem Ports (NETBLK-FUSE-216-68-32-0) FUSE-216-68-32-0 216.68.32.0 - 216.6 +8.47.255 To single out one record, look it up with "!xxx", where xxx is the handle, shown in parenthesis following the name, which comes first.
The little piece of code below obtains the network handle (anything within the parentheses) which works, but it only matches the first handle. What is the best way to match the second handle also? I thought maybe the /g modifier would work, but it doesn't (well, at least the way I have it). I plan on using this in a larger script to perform a whois query by the second handle.

Thanks,
Dru
#!/usr/bin/perl -w use strict; my $arin="/usr/bin/whois -h whois.arin.net"; my $ip = "216.68.40.234"; my $result = `$arin $ip`; if ($result =~ m/xxx/){ $result =~ m/\((.*?)\)/g; print "The handle is: $1\n"; print "The 2nd handle is: $2\n"; }

In reply to Regex Help 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.