in reply to Re: Is there a way to avoid copy function from overwriting old contents?
in thread Is there a way to avoid copy function from overwriting old contents?
You can run it once. It will create result_log and tmp files. Change the input my $value0 = 0; and run again ..Note: that it will append the result to the result_log. NOW change the my $value0 = 1; and run it again it will replace the result_log to have only recent output.So bottomline : After 1st true no matter how many false inputs it continues to append until it finds the true vondition again. So my question here is that , is it possible to stop replacing the old log and continue to append ? Note: I also found something strange. The line "this is simple" is appemded to the log file before the actual print.How is that possible ? -Thanks Ram#!/usr/bin/perl use strict; use warnings; use File::Copy; my $value0 = 1; #change this to 0 and execute a +nd back to one and execute my $value1 ='true'; open (INFO, "> tmp"); print INFO "this is simple\n"; close (INFO); open (FILE, ">> RESULT_LOG") ; print FILE " STATUS obtained : $value1\n"; if ($value0 == 1) { # If true then copies the informa +tion to the RESULT_LOG copy("tmp","RESULT_LOG");} else { print FILE "Check keyword supplied\n";} close(FILE);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Is there a way to avoid copy function from overwriting old contents?
by GrandFather (Saint) on Apr 12, 2011 at 02:24 UTC | |
|
Re^3: Is there a way to avoid copy function from overwriting old contents?
by furry_marmot (Pilgrim) on Apr 12, 2011 at 17:43 UTC | |
by justkar4u (Novice) on Apr 12, 2011 at 18:01 UTC | |
by furry_marmot (Pilgrim) on Apr 12, 2011 at 19:59 UTC |