zoukankan      html  css  js  c++  java
  • 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个参数
    ";exit 1};
        ($m,$n) = @_; #将参数赋值给变量  
        my $to_address  = $m;
    my $CurrTime = time2iso(time());
        my $to_address  = $m;
    
    
    
        my $from    = "From: $mail_user
    ";
        my $subject = "Subject: zjcap info
    ";
        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("
    
    ");
        $smtp->datasend("$message
    "); # 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 "开始处理
    ";
    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 $_."
    "}};
    [oracle@oadb sbin]$ perl s1.pl 
    开始处理
    
    

  • 相关阅读:
    [Java] java中的异常处理
    Jmeter之定时器
    Jmeter之检查点
    Jmeter之集合点
    Jmeter之关联
    Jmeter之参数化
    Jmeter测试WebService接口
    Jmeter测试MySQL数据库
    Jmeter测试HTTP接口
    使用Postman对HTTP接口进行功能测试
  • 原文地址:https://www.cnblogs.com/zhaoyangjian724/p/6199595.html
Copyright © 2011-2022 走看看