# __/AddStatus\____________ #| #| sub AddStatus { my @tempfile_a; my $to_add; $to_add = param('txt_status') . "\n"; my $whichfile; my $breaksread; $breaksread = 1; my $linenum; $linenum = 0; if ($chosen > $opnum) { $chosen = $chosen - $opnum; $whichfile = "closed.dat"; } else { $whichfile = "open.dat"; } open (CASEFILE, $whichfile) or dienice ("Can't open file $whichfile"); @readfile_a = ; close(CASEFILE); foreach $line (@readfile_a) { #see if we're on a break $testline = substr($line, 0, 2); if ($testline eq "\$.") { #if so increase breaksread $breaksread = $breaksread + 1; } #if it's not a break then see if the line is in the entry elsif ($breaksread == $chosen) { if ($testline eq "\$e") { print "boooo $linenum - $to_add
\n"; @tempfile_a[$linenum] = $to_add; $linenum = $linenum + $linenum; } } @tempfile_a[$linenum] = $line; $linenum = $linenum + 1; } # $whichfile = ">b" . $whichfile; # print "$whichfile
\n"; print @tempfile_a; # create a lock file my $lockfile; $lockfile="lock_the_file.loc"; while (-e $lockfile) { sleep 2; } open (LOCK,">$lockfile") || die ("Cannot open lock file!\n"); close (LOCK); open (CASEFILE, ">$whichfile"); print CASEFILE @tempfile_a; close(CASEFILE); unlink($lockfile); } #| #| End AddStatus #|_________________________________