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);
In reply to Re^2: Is there a way to avoid copy function from overwriting old contents?
by justkar4u
in thread Is there a way to avoid copy function from overwriting old contents?
by justkar4u
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |