use Geo::IPfree; use Regexp::Common qw/net/; use warnings; use strict; system("clear"); my $file2 = 'Traces.txt'; open my $in, '<', $file2 or die $!; open my $out, '>', 'To. of Traceroutes' or die $!; my $text = "End of Route"; my $var=0; while (my $line = <$in>) { if($line =~ /traceroute/){ #print $line; $var++;#just shows how many traceroutes are there in the file print {$out} "*End*\n"; } } print "$var \n";