in reply to File append not working. Any help?
Hi there,
I tried your code and add two print lines here to test it, and it looks fine to me!!!
And here the second print was appended to the first one.
my next Q is: How do you write to these files, can you give some example?
also you can see my version of your code here:
$tme=localtime(); my ($d,$m,$y) = (localtime)[3,4,5]; my $mdy1 = sprintf '%d-%d-%d', $d, $m+1, $y+1900; print "\nDate is:$mdy1\n"; if ($mdy1 eq "0-3-2015") {$mdy1 = "28-2-2015";} print "\nDate is:$mdy1\n"; $LOGFILE = "7252_Widevine_OemCrypto_Consolelog_User1"; $CONSOLE_LOGFILE = $LOGFILE.'_'.$mdy1.'.txt'; open CONSOLE_LOGF, ">", $CONSOLE_LOGFILE or die "Cannot open Console l +ogfile $CONSOLE_LOGFILE:$!"; system("pwd"); print CONSOLE_LOGF "[1st print]\n"; #<<<<<<<<<<<<<<< # Doing some operations here. close(CONSOLE_LOGF); $tme=localtime(); ($d,$m,$y) = (localtime)[3,4,5]; #my $mdy2 = sprintf '%d-%d-%d', $d-1, $m+1, $y+1900; my $mdy2 = sprintf '%d-%d-%d', $d, $m+1, $y+1900; print "\nDate is:$mdy2\n"; $LOGFILE1 = "7252_Widevine_OemCrypto_Consolelog_User1"; $CONSOLE_LOGFILE = $LOGFILE1.'_'.$mdy2.'.txt'; open(CONSOLE_LOGF, ">>", $CONSOLE_LOGFILE) || die "Cannot open Console + logfile $CONSOLE_LOGFILE: $!"; # ........... Here is where the previous contents are erased and new f +ile is created with new time(date is same here)..... system("pwd"); print CONSOLE_LOGF "[2nd print]\n"; #<<<<<<<<<<<<<<< # Doing some operations here. close(CONSOLE_LOGF);
|
|---|