#!/usr/bin/perl -w
use strict;
use CGI;
use DBI;
my $query = CGI::new();
my $blank = $query->param("blank");
my $dbh = DBI->connect("DBI:mysql:news", "root", "");
my $sth = $dbh->prepare("select * from newspw");
$sth->execute();
print "Content-type: text/html\n\n";
# filled options
if (!$blank)
{
while (my @data = $sth->fetchrow_array())
{
my $username=$data[1];
# format name; optional, only here because I have usernames
# stored as email addresses in the form: joe_ryan
my ($username1)=$username; my ($username2)=$username;
$username1 =~ s/([a-z])([a-z]+)_([a-z])([a-z]+)/$1/;
$username2 =~ s/([a-z])([a-z]+)_([a-z])([a-z]+)/$3/;
$username1 =~ tr/[a-z]/[A-Z]/;
$username2 =~ tr/[a-z]/[A-Z]/;
$username =~ s/([a-z])([a-z]+)_([a-z])([a-z]+)/$username1$2 $username2$4/;
print "\n";
}
}
# for the blank options
else
{
while (my @data = $sth->fetchrow_array())
{
print "\n";
}
}
$dbh = $dbh->disconnect();