CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate: Re: [gregarios] Database Unexpected Erasure Problem: Edit Log


May 21, 2002, 6:26 AM

Views: 8612
Re: [gregarios] Database Unexpected Erasure Problem

I have found a way to simulate the problem so it is caused on purpose in order to find a way to solve it and something interesting I have found out is the following:

if you have:

if ($var eq "") {

print "I'm here";


if ($var eq "") {



sometimes it still shows "I'm here" and does NOT exit meaning a bit later it remembers the contents of the var !!

So if this is right this one should help:

open(DATA, ">anyfile.txt");

print DATA @array;



sub check {

open(DATA, "+<anyfile.txt");



if ($content[0] eq "") {

open(DATA, ">anyfile.txt");

print DATA @array;




if ($a < 20) {




This will try to write the contents to the file 20 times again and again as long as the file has a content.

Another way is using temporary files i.e.:

1) Write the files content to a temp file

2) Have the script check if the temp file is empty

3) if it is not empty overwrite the original file with the temp file. This appears to be a secure possibility

Of course in step 3 you would not use Perl to overwrite the file but have Perl command the shell to do this like:

open (SHELL, "|blabla"):


This would help but on large apllication as the one I am using it for it would cause a lot of disk usage and maybe reduce the lifetime of the server's harddisk...

(This post was edited by sebastian on May 21, 2002, 6:30 AM)

Edit Log:
Post edited by sebastian (Novice) on May 21, 2002, 6:28 AM
Post edited by sebastian (Novice) on May 21, 2002, 6:30 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives