#!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 data 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://myinternalip_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://myexternaliplookup/phpwhois-4.2.2/example.php?query=$external_ip&output=normal"); my $content_externailip = $response_externalip->content; my $tree_externalip = HTML::Tree->new(); $tree_externalip->parse($content_externalip); print {$output_fh} $tree_externalip, "\n"; } } }