in reply to Writing a new file in Perl
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; }
Each time you call open, the file gets truncated. Either open it before the loop, and close after the loop, or open file for appending:
open FILE, ">>Google_1" or die $!
|
---|
In Section
Seekers of Perl Wisdom