GetDotted Domains

Viewing Thread:
"Flat text db- by demand! Proper Version"

The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.

Tue 20/02/01 at 23:18
Regular
Posts: 787
This tutorial comes in 2 parts. S find the parts that are necessary.
robin martin
rovogob
Tue 20/02/01 at 23:20
Posts: 0
ok now I know a lot of you have recently and in the past been moaning about why freeola doesn't get mysql database support. to be honest with you at first i was one of these people, however i researched flat text databases and i found that they could do everything that i needed to do and i'm sure that they can for you to. this tutorial will show you how to create a flat text database in perl for cgi.

right, i'm assuming that you already have a basic knowledge of perl so i'll begin by explaining how to create a flat text database.

basically all a flat text database is is a text file.

the syntax for creating a text file in perl is as follows:

open (name, " >filename.txt ");
print name " information \n";
close (name) ;

the name is a name of your choosing that will represent the file instead of having to type out the full path to the file every time.
the '>' in front of the path to the file means create or overwrite. so this means if the file doesn't exist then it will be created and if it does then all its information will be overwritten.
you may already know print as a function that displays information on the screen but it also has a second function, 'write'. when linked with files it has the function of writing to the file.
the close function is neccessary because if you wish to open the file at a later time during the same script your variables may become confused.


Tue 20/02/01 at 23:19
Posts: 0

ok so hopefully you've mastered creating files. now i guess your gonna need to read them.

the syntax for reading a file is:

open (name, " filename.txt ");
@array = ;
close (name) ;

the first line is exactly the same apart from you may notice the '>' is missing. this is because we are only reading the file not writing to it. the second line basically stores all the information from the filehandle(the file) into an array. this array can then be split into various scalars etc to suit your needs.

the final line is the same as above.

now lets move on to something maybe, maybe not less important, adding to the end of files.
the syntax for the this will probably (hopefully!) look familiar.

open (name, ">> filename.txt ");
print name " extra information \n";
close (name) ;

the only difference between this and creating files is the extra '>' on the first line. this basically tells perl to add to the end of the file not overwrite it.

for example if we had the file 'people.txt' that contained the information:

david
fred
ben
john

and we opened the file using:
open (name, ">> people.txt ");
whatever we put on the next line will be added to the end of the file.
for example:

print name "harry\n";
close (name) ;

this extra information being added would result in the file looking like the following.

david
fred
ben
john
harry



Tue 20/02/01 at 23:19
Posts: 0

hopefully your still with me. we're almost there. the final thing i will show you how to do is renaming files. this is probably the easiest thing to learn out of the whole of the tutorial.

the syntax is as follows:

rename "oldname.txt", "newname.txt";

this is so simple it doesn't even need explaing. if it does email me

[email protected]

my websited is hosted by freeola it is an online game check it out at

www.thegaragerpg.org.uk


robin martin
Tue 20/02/01 at 23:18
Posts: 0
This tutorial comes in 2 parts. S find the parts that are necessary.
robin martin
rovogob

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Continue this excellent work...
Brilliant! As usual the careful and intuitive production that Freeola puts into everything it sets out to do, I am delighted.
I am delighted.
Brilliant! As usual the careful and intuitive production that Freeola puts into everything it sets out to do. I am delighted.

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.