in reply to delete user from database

OK, Two methods:
  1. Use the Perl Data Base Interface (DBI) module
    This is a Perl module that lets you write database code in standard SQL regardlesss of the actual database you are using, including flat-files. You'll pretend you're using an actual rdbms, write your code in sql, and DBI will take care of translating that into the commands that will interface with your flat-file. A good introduction to the Perl DBI is http://www.perl.com/pub/a/1999/10/DBI.html. Then, if you decide later on to switch to a real db, you'll have just a few lines of your code to change as you tell DBI which type of db to interface with, instead of the whole thing to re-write. All this work on DBI's part does come at a price - it adds a layer of interpretation and slows things down a bit. But you won't notice it witha flat-file until your user list approaches 1,000 or so rows.

  2. Raw Perl. Here you go:
Suppose your user "database" is a flat-file that looks like this:
username|password|fname|lname|user_info
Your html form in which you select the user to delete is going to have a drop down:
<form action="myscript.pl"> <select name="user"> <OPTION VALUE="uname_1">user name 1 <OPTION VALUE="uname_2">user name 2 </select> </form>
Then your Perl script is going to look like:
# use the CGI module, this automates processing of form input and take +s care of a lot of security issues too use CGI; my $query = new CGI; $user_to_delete = $query->param('user'); #load the user file into an array open(FILE, '<user_data_file.txt'); @user_data = <FILE>; close(FILE); #to find the row with your user, cycle through the rows, parsing each +one and looking for the user name, and write all lines back to the us +er database except the one for the user in question open(FILE, '>user_data_file.txt'); for $i (0 .. $#user_data) { @this_user_info = split(/\|/, $user_data[$i]); if ($this_user_info[0] eq $user_to_delete) { #do nothing } else { print FILE "$user_data[$i]\n"; } } close(FILE);
This is very basic. You should add code for file locking, for example. And this could could be more elegant with the use of "unless" instead of the if-else.