Hi, I've a file which is opened for writing and then i close it. Again i open the same file for appending to its contents, but its not appending, its removing the older contents and freshly starting. Any help on whats the issue?
$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"); # 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"); # Doing some operations here. close(CONSOLE_LOGF);
Thanks

In reply to File append not working. Any help? by ramki067

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.