I need to regex the next line of a given match and have contents of next line which will be a domain or ip address assign as a variable. The match will either be a domain or an ip on the external ip match on the internal it will always be an ip. The match will be after the headings. Some domains will have www. at the beginning and i need to get rid of this and just have domain.com or .net or whatever
#!perl
use strict;
use warnings;
use DateTime;
use LWP::UserAgent;
use HTML::Tree;
my $newline;
my $textfile_new;
my @textfiles = <*.txt>;
foreach my $textfile (@textfiles) {
if ($textfile =~ /(\d+.\d+.\d+.\d+.txt)/) {
my ($output_file) = $textfile =~ /(\d+.\d+.\d+.\d+).txt/;
open(my $input_fh, '<', $textfile)
or die "Failed to open $textfile: $!";
open(my $output_fh, '>', "${output_file}_report.txt")
or die "Failed to open ${output_file}_report.txt: $!";
print $output_fh "my description of stuff.\n\n";
my $ua = new LWP::UserAgent;
$ua->timeout(10); #10 second timeout
$ua->proxy(['http'], 'http://mywebproxy:8080');
while ( <$input_fh> ) {
print $output_fh $_;
#need to regex for the following then use LWP to get d
+ata based on the IP on the next line.
my $internal_ip =~ /Internal IP\n(\d+.\d+.\d+.\d+)/;
my $external_ip =~ /SIP\(s\)\n(\d+.\d+.\d+.\d+)/;
#lwp stuff
my $response_internalip = $ua->get("http://myinternali
+p_referentialdatasearch");
my $content_internalip = $response_internalip->content
+;
my $tree_internalip = HTML::Tree->new();
$tree_internalip->parse($content_internalip);
print {$output_fh} $tree_internalip, "\n";
my $response_externalip = $ua->get("http://myexternali
+plookup/phpwhois-4.2.2/example.php?query=$external_ip&output=normal")
+;
my $content_externailip = $response_externalip->conten
+t;
my $tree_externalip = HTML::Tree->new();
$tree_externalip->parse($content_externalip);
print {$output_fh} $tree_externalip, "\n";
}
}
}