in reply to file duplication error
Well written code should be mostly self documented. Have you considered pods instead? (Note: this is only a minor point!)#!/usr/bin/perl #************* File Header ******************************
Alsouse CGI qw/:standard/; my @dataWrite; my @dataRead; my $x;
my (@dataWrite, @dataRead, $x);
Really no need for these!undef @dataWrite; undef @dataRead;
Ouch! Didn't you get told to always (yes, always!) check the return value of open()'s?!?open (fileReadWrite,"../Rules1.txt"); my @dataRead = <fileReadWrite>;
Also, nowadays it's generally recommended to use lexical FHs and the three-args form of open(). Hence
But are you sure it's "ReadWrite"? (I'm contending that it's not an especially well chosen name...)open $fileReadWrite, '<', '../Rules1.txt' or die $!;
Ouch!foreach my $value1 (@dataRead) { push @dataWrite , $value1; }
@dataWrite=@dataRead;
push @dataWrite, "Code1\n";So this is really all you wanted to do... hint: '>>'.
open(fileOUT,">../Rules1.txt") or dienice("Can't open counter.txt: $!");;Ditto as above wrt open().
What is dienice()? It's sensible to post minimal, but still working examples!
Don't! There's no point in reinventing the wheel and risking to do it wrong, but possibly for educational purposes. So since you're using CGI.pm in the first place let it do it for you!print "Content-type: text/html\n"; print("\n");
|
|---|