I have a table "customer_table" with the following fields: Id int, firstname varchar(64), lastname varchar(64), emailaddress varchar(64) not null primary key city varchar (32),
Can some one help me and show me how to print only records that matches a given regexp using, for example if I run: #> getRecord.pl A+ should return all record from the database if the first name, last name, or email address starts with a capital A OR: #> getRecord.pl should return all records from the table, which I have it this way and it works just fine: use DBI; my $dataBaseDriver = "DBI:mysql"; my $dataBaseName = "test"; my $dataBaseUser = "user"; my $dbUserPass = "user1234"; my $tableName = "my_table"; #---------------------------------------# # connect to the database # #---------------------------------------# my $dbh = DBI->connect("$dataBaseDriver:$dataBaseName", $dataBaseUser, $dbUserPass, { RaiseError => 1, AutoCommit => 0 }) || die "ERROR-1: Couldn't connect to $dataBaseHost: " . DBI->errstr(); print "Connection to the database successful.\n"; #---------------------------------------# # querying the database # #---------------------------------------# my $sth = $dbh->prepare("SELECT * FROM $tableName"); $sth->execute(); #---------------------------------------# # print the data # #---------------------------------------# while(my $ref = $sth->fetchrow_hashref()) { print "ID: $ref->{'Id'}\n"; print "First Name: $ref->{'firstname'}\n"; print "Last Name: $ref->{'lastname'}\n"; print "Email Address: $ref->{'emailaddress'}\n"; print "City: $ref->{'city'}\n"; } $sth->finish(); $dbh -> disconnect(); Thanks for your help Berti -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/