zoukankan      html  css  js  c++  java
  • perl mojo use utf8 和no utf8

    mojo utf8
    
    centos6.5:/root#cat t1.pl 
    use Mojolicious::Lite;  
    use JSON qw/encode_json decode_json/;    
    use Encode;  
    no strict;  
    use JSON;   
    use Data::Dumper;  
    #no  utf8;  
    # /foo?user=sri  
     get '/admin/api/menu' => sub {  
              my $c = shift;  
              print "测试更健康
    ";  
             open (LOG1 ,"<",'11.out') or die  $!;  
                         while (<LOG1>) {  
                         my $phone='18072722237';  
                        #2016-03-09 09:35:12,380 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为132435,本验证码5分钟内有效。 to phoneNo:18072722237 succeed!  
                         #   my $d=encode_utf8('验证');  
                         my $d='验证';
                        if ( ($phone) and ($_ =~/$phone/) and ($_ =~/$d/) ){$str=$_;  
                    #   my $d=encode_utf8('验证');  
                        print "1111111111111111
    "; 
                        }};  
                          
                        close LOG1;  
              $c->render(text =>  "测试更健康" );  
    };  
                         
      
      
      app->start;
    centos6.5:/root#morbo t1.pl 
    Server available at http://127.0.0.1:3000
    [Thu Mar  9 13:55:15 2017] [debug] GET "/admin/api/menu"
    [Thu Mar  9 13:55:15 2017] [debug] Routing to a callback
    Wide character in print at /root/t1.pl line 11.
    测试更健康
    [Thu Mar  9 13:55:15 2017] [debug] 200 OK (0.000833s, 1200.480/s)
    
    
    
    此时没有输出 111111111111 ,说明没有匹配到,
      
      
      
      
    centos6.5:/root#cat t1.pl 
    use Mojolicious::Lite;  
    use JSON qw/encode_json decode_json/;    
    use Encode;  
    no strict;  
    use JSON;   
    use Data::Dumper;  
    #no  utf8;  
    # /foo?user=sri  
     get '/admin/api/menu' => sub {  
              my $c = shift;  
              print "测试更健康
    ";  
             open (LOG1 ,"<",'11.out') or die  $!;  
                         while (<LOG1>) {  
                         my $phone='18072722237';  
                        #2016-03-09 09:35:12,380 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为132435,本验证码5分钟内有效。 to phoneNo:18072722237 succeed!  
                          my $d=encode_utf8('验证');  
                         #my $d='验证';
                        if ( ($phone) and ($_ =~/$phone/) and ($_ =~/$d/) ){$str=$_;  
                        print "1111111111111111
    "; 
                        }};  
                          
                        close LOG1;  
              $c->render(text =>  "测试更健康" );  
    };  
                         
      
      
      app->start;
    centos6.5:/root#morbo t1.pl 
    Server available at http://127.0.0.1:3000
    [Thu Mar  9 13:56:16 2017] [debug] GET "/admin/api/menu"
    [Thu Mar  9 13:56:16 2017] [debug] Routing to a callback
    Wide character in print at /root/t1.pl line 11.
    测试更健康
    1111111111111111
    [Thu Mar  9 13:56:16 2017] [debug] 200 OK (0.000998s, 1002.004/s)
    
    
    打开utf8 的情况下, 如果需要匹配中文  需要  encode_utf8('验证'); 
    
    
    
    
    /********************************************************************8/
    
    
    关闭utf 8情况:
    
    centos6.5:/root#cat t1.pl 
    use Mojolicious::Lite;  
    use JSON qw/encode_json decode_json/;    
    use Encode;  
    no strict;  
    use JSON;   
    use Data::Dumper;  
    no  utf8;  
    # /foo?user=sri  
     get '/admin/api/menu' => sub {  
              my $c = shift;  
              print "测试更健康
    ";  
             open (LOG1 ,"<",'11.out') or die  $!;  
                         while (<LOG1>) {  
                         my $phone='18072722237';  
                        #2016-03-09 09:35:12,380 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为132435,本验证码5分钟内有效。 to phoneNo:18072722237 succeed!  
                         # my $d=encode_utf8('验证');  
                         my $d='验证';
                        if ( ($phone) and ($_ =~/$phone/) and ($_ =~/$d/) ){$str=$_;  
                        print "1111111111111111
    "; 
                        }};  
                          
                        close LOG1;  
              $c->render(text =>  "测试更健康" );  
    };  
                         
      
      
      app->start;
    centos6.5:/root#morbo t1.pl 
    Server available at http://127.0.0.1:3000
    [Thu Mar  9 13:58:15 2017] [debug] GET "/admin/api/menu"
    [Thu Mar  9 13:58:15 2017] [debug] Routing to a callback
    测试更健康
    1111111111111111
    [Thu Mar  9 13:58:15 2017] [debug] 200 OK (0.000852s, 1173.709/s)
      
     此时   my $d='验证'; 可以匹配到
     
     
     centos6.5:/root#cat t1.pl 
    use Mojolicious::Lite;  
    use JSON qw/encode_json decode_json/;    
    use Encode;  
    no strict;  
    use JSON;   
    use Data::Dumper;  
    no  utf8;  
    # /foo?user=sri  
     get '/admin/api/menu' => sub {  
              my $c = shift;  
              print "测试更健康
    ";  
             open (LOG1 ,"<",'11.out') or die  $!;  
                         while (<LOG1>) {  
                         my $phone='18072722237';  
                        #2016-03-09 09:35:12,380 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为132435,本验证码5分钟内有效。 to phoneNo:18072722237 succeed!  
                          my $d=encode_utf8('验证');  
                         #my $d='验证';
                        if ( ($phone) and ($_ =~/$phone/) and ($_ =~/$d/) ){$str=$_;  
                        print "1111111111111111
    "; 
                        }};  
                          
                        close LOG1;  
              $c->render(text =>  "测试更健康" );  
    };  
                         
      
      
      app->start;
    centos6.5:/root#morbo t1.pl 
    Server available at http://127.0.0.1:3000
    [Thu Mar  9 13:59:40 2017] [debug] GET "/admin/api/menu"
    [Thu Mar  9 13:59:40 2017] [debug] Routing to a callback
    测试更健康
    [Thu Mar  9 13:59:40 2017] [debug] 200 OK (0.00107s, 934.579/s)
    
    
    此时 关闭utf8 不需要 $d=encode_utf8('验证');
      

  • 相关阅读:
    博客索引
    【转载】学习顺序:顶级会议 ----> 顶级期刊 ------> 基础教材(博客) / 论文复现
    【神游篇00】关于自己的日常学习记录
    【1】ML简介
    【2】Neural Network学习
    【1】NNDL简介
    【1】Deep Learning简介
    【1】PRML简介
    【1】BRML简介
    图集压缩,,命令行工具
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349837.html
Copyright © 2011-2022 走看看