coopermarsh
MIS
What is this line of perl doing?
I need to modify the script below to replace any error with the original IP
Code:
print "$who -> $1\n" if $lookup=~m{Name:\s+(.+)}i;
I need to modify the script below to replace any error with the original IP
Code:
#!/usr/bin/perl
use strict;
use warnings;
my ( $base, $subnet );
sub probe {
my ($who) = @_;
my $lookup = `nslookup $who`;
print "$who -> $1\n" if $lookup=~m{Name:\s+(.+)}i;
}
while (<>) {
chomp;
s/\|/ /g;
my @F = split /]/;
for my $range (@F) {
$range =~ s/^\s+//;
$range =~ s/\s+$//;
if ( $range =~ m{ (\d+\.\d+\.\d+\.\d+) }x ) {
probe($range);
next;
}
( $base, $subnet ) = $range =~ m{ (\d+\.\d+\.\d+\.) \[ (.+) }x;
my @FF = split / /, $subnet;
for my $node (@FF) {
probe( $base . $node );
}
}
}
1;