open (FILEHANDLE, "path/to/file/database.dat");
print FILEHANDLE "data|you|want|saved";
This is the basic way to write to a textfile database with PERL. FILEHANDLE should be changed to what you want. Could be DATA, FILE, whatever you want. But each different database that you open should have a different filehandle. The path in the quotes and the filename tells the script the location of the text file you want to write to.
This file can be .txt, .dat, or for my own scripts I often use .cms (a file extension I created from my initials). As long as the file is capable of being written to, your script can write to it.
The second line tells the script what to write to the database. If you are familiar with databases, you have the database delimited by something. This will tell the script what pieces of info in the database are. These are just like field columns in MySQL (more or less). I like to use pipes "|" to delimit my fields. But you can use pretty much anything, but stay away from common strokes such as commas because if anyone types a comma in whatever their input is, you will have a messed up database. But a pipe is rarely used by people filling out forms whos info is saved to a database so they tend to be safe. Some people like double colons "::" If you have a database with users' usernames, passwords, and E-mail addresses and you want to save a new user's info to the database, you could have:
open (USERS, ">cgi-bin/profiler/users/userdatabase.dat");
print USERS "$username|$password|$email\n";
Of course you will have to set the scalars used in that sample to something which will probably be done with a sign up form (registration form where the users input the username and password they want and their E-mail address).
The > in the first line tells the script to save over the information already in the database. If you always want new info to be saved over the old and do not want the old info in there, just have the single > and the new info will replace the old.
But in the example above, you would obviously want to save all users' info to the database and not copy over the previous users info. So you should have >> instead of just one. This will tell the script to take the new user's info and append it to the bottom of the database. Which will keep the old information intact.
You can create a textfile on your harddrive called userdatabase.dat and upload it to your server and the script will automatically use it as the database. But if you run the script without uploading the database, most servers will automatically create the file.
This is just the tip of the iceberg. You will want to learn about file locking. if you are creating a database that a lot of people will be saving information to at the same time, it keeps the database's attention as it prints one person's info and then saves another person's or else you could have two peoples' information mixing into one line.
You will also need to learn the proper ways to draw the information from the database for use in your scripts.