use Regexp::Common qw/net/; system("clear"); my $file_content = ""; my $parsed = ""; open(INPUT,"){ my $line = $_; chomp($line); $file_content .= $line; } $_ = "\n $file_content"; while(/hops(.+)Trace/mg){ print $1, "\n" if /($RE{net}{IPv4})/; open FILE, ">Google_1" or die $!; print FILE "Important Information \n $1"; close FILE; }