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 reply to Re: Writing a new file in Perl
by zwon
in thread Writing a new file in Perl
by maheshkumar
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |