1. [root@wx03 mojo]# cat test.pl
  2. use Mojolicious::Lite;
  3. use JSON qw/encode_json decode_json/;
  4. use Encode;
  5. no strict;
  6. use JSON;
  7. use Data::Dumper;
  8. # /foo?user=sri
  9. get '/admin/api/menu' => sub {
  10. my $c = shift;
  11. print "测试更健康\n";
  12. open (LOG1 ,"<",'/data01/applog_backup/zj-api01-catalina.out') or die $!;
  13. while (<LOG1>) {
  14. my $phone='18072722237';
  15. #2016-03-09 09:35:12,380 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为132435,本验证码5分钟内有效。 to phoneNo:18072722237 succeed!
  16.  
  17. if ( ($phone) and ($_ =~/$phone/) and ($_ =~/SMSUtils/) ){$str=$_;
  18.  
  19. my $x='验证';
  20. print "\$x is $x\n";
  21. my $d=encode_utf8('验证');
  22. print "\$d is $d\n";
  23.  
  24. print "1-------\$str is $str\n";
  25. next if ($str !~ /$d/);
  26. print "2--------\$str is $str\n";
  27. #push (@arr1 ,decode_utf8($str));
  28. push (@arr1 ,$str);
  29. }};
  30.  
  31. close LOG1;
  32. $c->render(json => \@arr1 );
  33. };
  34.  
  35. app->start;
  36.  
  37. [root@wx03 mojo]# morbo test.pl
  38. Server available at http://127.0.0.1:3000
  39. Wide character in print at /root/mojo/test.pl line 10.
  40. 测试更健康
  41. Wide character in print at /root/mojo/test.pl line 19, <LOG1> line 1.
  42. $x is 验证
  43. $d is 验证
  44. 1-------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为813231,本验证码30分钟内有效。 to phoneNo:18072722237 succeed!
  45.  
  46. 2--------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为813231,本验证码30分钟内有效。 to phoneNo:18072722237 succeed!
  47.  
  48. Wide character in print at /root/mojo/test.pl line 19, <LOG1> line 3.
  49. $x is 验证
  50. $d is 验证
  51. 1-------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的813231,本30分钟内有效。 to phoneNo:18072722237 succeed!
  52.  
  53. Wide character in print at /root/mojo/test.pl line 19, <LOG1> line 4.
  54. $x is 验证
  55. $d is 验证
  56. 1-------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的813231,本30分钟内有效。 to phoneNo:18072722237 succeed!
  57.  
  58. 此时$d$x都正常显示
  59.  
  60. [root@wx03 mojo]# cat c1.pl
  61. use Encode;
  62. my $x='验证';
  63. print "\$x is $x\n";
  64. my $d=encode_utf8('验证');
  65. print "\$d is $d\n";
  66. [root@wx03 mojo]# perl c1.pl
  67. $x is 验证
  68. $d is 验证
  69.  
  70. 说明encode_utf8 必须用在utf8编码环境

perl encode_utf8必须用在utf8环境的更多相关文章

  1. encode_json 会对给定的Perl的数据结构转换为一个UTF-8 encoded, binary string.

    use JSON qw/encode_json decode_json/ ; use Encode; my $data = [ { 'name' => 'Ken' , 'age' => 1 ...

  2. C、Shell、Perl基于Tomcat开发CGI程序环境配置

    基于Tomcat7.0版本号配置CGI开发环境,步聚例如以下: 以我的Tomcat7安装文件夹为例:TOMCA_HOME = /Users/yangxin/Documents/devToos/java ...

  3. perl encode_utf8 和decode_utf8

    encode_utf8 等于 $octets = encode_utf8($string); 这个字符串 在$string 在Perl的内部格式,返回结果是作为一个顺序的字节. 因为所有的可能的字符串 ...

  4. Eclipse 完全 设置UTF-8 环境

    当开始一个新的Java项目时,最好将整个环境设置为UTF-8 一般通过如下几步来设置: 1: 设置工作空间的编码格式:Window -> Preferences -> General -& ...

  5. 理解perl的编码转换——utf8以及乱码

    工作需要,闲暇之余,仔细研究了一下脚本乱码的问题 1. vim新建的文件 1)在linux命令行 vim命令建立的文件,如果内容中不出现中文,默认是ASCII.那么用notepad++打开的时候,就是 ...

  6. perl encode_json 会产生 UTF-8 (binary) string decode_json 需要一个 UTF-8 (binary) string

    encode_json $json_text = encode_json $perl_scalar Converts the given Perl data structure to a UTF-8 ...

  7. perl use utf8

    utf8 Perl编译 来启用/禁用 UTF-8(or UTF-EBCDIC) 在源代码里 简洁: use utf8; no utf8; # Convert the internal represen ...

  8. perl unload gbk oracle 数据库

    perl unload gbk Oracle 数据库 use Encode; if ( $#ARGV < 0 ){ print "请输入一个文件\n"; exit(-1); ...

  9. 通过demo搞懂encode_utf8和decode_utf8

    perl 编码问题: use utf8表示代码使用UTF-8写的 [root@wx03 0710]# cat a1.pl #use utf8; my $str='测试utf8字符集'; print $ ...

随机推荐

  1. IE读取并显示本地图像文件的方法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. document.domain与js跨域的问题

    以前如果要使iframe里面的脚本能访问parent的内容,但iframe和parent的二级域名相同,那一般都会在两者都写上document.domain="xxx.com" 以 ...

  3. float 保留两位小数

    1.页面运算格式化数字 页面上有时候会用到数字的运算,运算过后会出现1.5999999999999这么长的数字,需要格式化数字,比如保留两位有效数字 首先导入这个标签 <%@ taglib ur ...

  4. MFC技术内幕系列之(四)---MFC消息映射与消息传递内幕

    ////////////////////////////////////////////////////////////////////////////////////                 ...

  5. Tour(KM算法)

    Tour Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others) Total Submi ...

  6. 【MongoDB】windows平台搭建Mongo数据库复制集(相似集群)(一)

    Replica  Sets(复制集)是在mongodDB1.6版本号開始新增的功能.它能够实现故障自己主动切换和自己主动修复功能成员节点的功能,各个DB之间的数据全然一致,大大减少了单点故障的风险. ...

  7. C# 中根据datetime的值来计算属于本年的第几周,类似delphi中的weekoftheyear功能

    /// <summary> /// 获得今天是今年的第几周 /// </summary> /// <param name="year">< ...

  8. NSnotificationCenter 正确使用姿势, removeObject 探索

    最近在做平板的过程中,发现了一些很不规范的代码.偶然修复支付bug的时候,看到其他项目代码,使用通知的地方没有移除,我以为我这个模块的支付闪退是因为他通知没有移除的缘故.而在debug和看了具体的代码 ...

  9. ubuntu中在线升级python

    sudo add-apt-repository ppa:fkrull/deadsnakes-python2.7 sudo apt-get update sudo apt-get upgrade 笔记

  10. BZOJ 3282: Tree( LCT )

    LCT.. -------------------------------------------------------------------------------- #include<c ...