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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



sebastian
Novice

May 21, 2002, 6:26 AM


Views: 3468
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 "") {

exit;

}



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;

close(DATA);

✓

sub check {

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

@content=<DATA>;

close(DATA)

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

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

print DATA @array;

close(DATA)

}

$a++;

if ($a < 20) {

&check;

}

}



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"):

close(SHELL);



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