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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |