perl oracle utf-8 结果匹配中文字符

[oracle@oadb sbin]$ cat s1.pl 
#!/usr/bin/perl     
use DBI;    
use Encode;
use HTTP::Date qw(time2iso str2time time2iso time2isoz);  
use Net::SMTP;
sub send_mail{
if (@_ != 2){print "请输入2个参数\n";exit 1};
    ($m,$n) = @_; #将参数赋值给变量  
    my $to_address  = $m;
my $CurrTime = time2iso(time());
    my $to_address  = $m;



    my $from    = "From: $mail_user\n";
    my $subject = "Subject: zjcap info\n";
    my $info = "$CurrTime--$n";
     my $message = <<CONTENT; 
     $info
CONTENT
    my $smtp = Net::SMTP->new($mail_server);

    $smtp->auth($mail_user, $mail_pwd) || die "Auth Error! $!";
    $smtp->mail($mail_user);
    $smtp->to($to_address);

    $smtp->data();             # begin the data
    $smtp->datasend($from);    # set user
    $smtp->datasend($subject); # set subject
    $smtp->datasend("\n\n");
    $smtp->datasend("$message\n"); # set content
    $smtp->dataend();
    $smtp->quit();
}
my $dbName = 'oadb';    
my $dbUser = 'query';    
my $dbUserPass = 'kx';    
my $dbh = DBI->connect("dbi:Oracle:$dbName", $dbUser, $dbUserPass) or die "can't connect to database ";  
my $sql = "select count(*) from VXSPACE.FORMMAIN_1530";    
my $sth = $dbh->prepare($sql);    
  
$sth->execute(); 

my  $var = $sth->fetchrow_array();


print "开始处理\n";
my $sql = "select field0001 from (select * from vxspace.FORMMAIN_1530 a  where a.field0001 like '%工资%' order by 4 desc) where rownum <20";    
my $sth = $dbh->prepare($sql);    
$sth->execute();    
while (my  @arr=( $sth->fetchrow_array())){ 
      foreach (@arr){
       push (@arr2,encode_utf8($_));
                  };
}; 
    foreach (@arr2){if ($_=~/太原/){print $_."\n"}};
[oracle@oadb sbin]$ perl s1.pl 
开始处理


posted @ 2016-07-14 16:36  czcb  阅读(314)  评论(0编辑  收藏  举报