well i am writing a simple code in which the file contents of .txt file are read into an array. Next the contents of this array are copied into another array . When the contents of the new arrray are modified, the changes are also visible in the old array from which the data was copied from. This new array is then written to the same file. As a result, file data duplication is occuring......

Any help will be appreciated. Thanks.

################### Code Snippet########################
#!/usr/bin/perl #************* File Header ****************************** # File Name : nas_add_new_operation_url_logic.cgi # Module : WebInterfaces # Notes : Logic page for writing new Oeration URL along with ac +cess rules # into Rules.txt # History : $Date: 26/01/05 12:34 $ $Revision: 3 $ # All Rights Reserved, Copyright (C) 2004, Hitachi, Ltd. #********************************************************* use CGI qw/:standard/; my @dataWrite; my @dataRead; my $x; undef @dataWrite; undef @dataRead; open (fileReadWrite,"../Rules1.txt"); my @dataRead = <fileReadWrite>; foreach my $value1 (@dataRead) { push @dataWrite , $value1; } push @dataWrite, "Code1\n"; open(fileOUT,">../Rules1.txt") or dienice("Can't open counter.txt: $!" +);; flock(fileOUT,2); seek(fileOUT,0,0); foreach my $value3 (@dataWrite) { print fileOUT $value3; } close(fileOUT); print "Content-type: text/html\n"; print("\n"); ###########################################################

20050201 Janitored by Corion: Added formatting


In reply to file duplication error by Roy.Amitabh

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.