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.
rob martin
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
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
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.