Perl DBD :: CSV db handler相同的范围

时间:2011-11-26 11:02:03

标签: perl dbd

在我的perl脚本中,我有两个从main调用的子例程。 perl编译器在以下警告下标记

  

“my”变量$ dbh掩盖了同一范围内的早期声明

用于子程序a和b

#!/usr/bin/perl -w

 my $dbh = DBI->connect("dbi:CSV","","");

 $dbh->do ("CREATE TABLE a (Id INTEGER PRIMARY KEY, Job_Id INTEGER ,)") or die "Cannot prepare: " . $dbh->errstr ();

 $dbh->disconnect;

 a();

 b();

 ############## SUBROUTINE
 sub a {

   my $dbh = DBI->connect("dbi:CSV","","");

   $dbh->do ("INSERT...") or die "Cannot prepare: " . $dbh->errstr ();

   $dbh->disconnect;

 }

 sub b {

   my $dbh = DBI->connect("dbi:CSV","","");

   $dbh->do ("INSERT...") or die "Cannot prepare: " . $dbh->errstr ();

   $dbh->disconnect;

 }

0 个答案:

没有答案