in reply to DBD::DBM file creation

There must be some way to have the set of tabular data not each be their own separate files.
The .lck file is created by DBD::DBM, if you don't need locking, you can turn locking off and that file won't be created. The other two files are created by your underlying DBM implemnetation, some of those create only a single file per table and some create two files per table, that's how DBM works.
If I have 100 tables, I can't handle 300 files in one directory just for the database to work.
What's wrong with 300 files? The whole point of a database is that you shouldn't need to worry about how it physically stores the data so the fact that there are multiple files is really irrelevant. You will be using SQL to CREATE and DROP tables, the fact that creating and dropping happens to create multiple files, doesn't really impact the basic SQL operations. You will never actually handle the files as files, only as SQL tables, the same way you would any SQL table. But, in any case, if that bothers you, use DBD::SQLite which stores all tables for a given database in a single file.
Second question is seems more of an SQL question but when you SELECT something from the table such as: SELECT phone FROM user WHERE user_name < 'Fred'; To store the results, you could use: my $var = SELECT phone FROM user WHERE user_name < 'Fred';
Well, that's actually a DBI question. You can put the reuslts of a query in a variable with DBI's $dbh->selectrow_array, $dbh->selectall_arrayref, etc. or prepare and execute a statement handle and use a loop with $sth->fetch or $sth->fetchrow_harshref, etc.

While I agree with the other posters that for most production work (but by no means all), a full RDBMS like PostgreSQL or MySQL is better than DBD::DBM, but since you appear to be in the early learning stages, DBD::DBM should work fine for you - you can learn basic SQL and DBI with it just fine.

disclaimer I'm the author of DBD::DBM so I'm prejudiced. OTOH, the reason it is included in the DBI distribution is because it is sufficient for learning the basics of DBI access to databases.

Replies are listed 'Best First'.
Re^2: DBD::DBM file creation
by aquarium (Curate) on Nov 30, 2004 at 12:47 UTC
    I forgot to address your question about 300 files directly. What i meant to say was, if you learn the basics of databases, including how to design them properly by normalization, then you should end up with a set of database tables (a few system level files?) that can store/retrieve/represent a much larger set of HTML tables, as long as you can correctly abstract/normalize the common facts about those tables. The MySQL book is good....if you want to learn practical mysql (in perl) as well as getting your breakfast of database concepts and basic SQL.
    the hardest line to type correctly is: stty erase ^H