dru145 has asked for the wisdom of the Perl Monks concerning the following question:
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.[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.
#!/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"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex Help
by japhy (Canon) on Sep 07, 2001 at 02:07 UTC | |
by dru145 (Friar) on Sep 07, 2001 at 07:37 UTC | |
|
Re: Regex Help
by demerphq (Chancellor) on Sep 07, 2001 at 02:09 UTC | |
by dvergin (Monsignor) on Sep 07, 2001 at 02:51 UTC | |
by demerphq (Chancellor) on Sep 07, 2001 at 03:26 UTC | |
|
Re: Regex Help
by Cine (Friar) on Sep 07, 2001 at 01:54 UTC |