#!/usr/bin/perl -w use DBI; my $count = 0;
my $dbh = DBI->connect("DBI:mysql:database=clientInfo;host=192.168.1.22", "wuwu", "123456", {'RaiseError' => 1});
#统计总人数 my $countsth = $dbh->prepare("select * from clientInfo where username like /"%_wu/";"); $countsth->execute();
while(my $countref = $countsth->fetchrow_hashref()) { my $name=$countref->{username}; if( length($name) >2 ) { print "username: $countref->{username}/n"; $count++; } }
$dbh->disconnect();