- 论坛徽章:
- 7
|
本帖最后由 b114213903 于 2015-02-05 16:13 编辑
- use Parallel::ForkManager;
- use DBI;
- my $max_procs = 100;
- my $pm = new Parallel::ForkManager($max_procs);
- for(my $i=1;$i<=100;$i++){
- $pm->start($i) and next;
- for(1..20){
- my $dbh = DBI->connect("DBI:mysql:database=***(数据库名);host=***(数据库地址)", "***(数据库用户名)", "***(数据库密码)", {'RaiseError' => 1});
-
- my $sth = $dbh->prepare( "SELECT * FROM `***(数据表名)` WHERE `***(数据表关键词)` = '***(数据表关键词的值)'" );
- $sth->execute();
- if(my @A=$sth->fetchrow_array()){
- print "$i\t$_\t@A\n";
- }else{
- print "$i\t$_\tNo hits\n";
- }
- $sth->finish();
- $dbh->disconnect();
- }
- $pm->finish();
- }
- $pm->wait_all_children;
- print "Finished!\n"
复制代码 试试这样可行不?! |
|