Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Writing a new file in Perl

by zwon (Monsignor)
on Jul 05, 2012 at 11:12 UTC ( #980029=note: print w/ replies, xml ) Need Help??


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 $!


Comment on Re: Writing a new file in Perl
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://980029]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2015-07-30 23:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls