[root@wx03 mojo]# cat test.pl
use Mojolicious::Lite;
use JSON qw/encode_json decode_json/;
use Encode;
no strict;
use JSON;
use Data::Dumper;
# /foo?user=sri
get '/admin/api/menu' => sub {
my $c = shift;
print "测试更健康\n";
open (LOG1 ,"<",'/data01/applog_backup/zj-api01-catalina.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! if ( ($phone) and ($_ =~/$phone/) and ($_ =~/SMSUtils/) ){$str=$_; my $x='验证';
print "\$x is $x\n";
my $d=encode_utf8('验证');
print "\$d is $d\n"; print "1-------\$str is $str\n";
next if ($str !~ /$d/);
print "2--------\$str is $str\n";
#push (@arr1 ,decode_utf8($str));
push (@arr1 ,$str);
}}; close LOG1;
$c->render(json => \@arr1 );
}; app->start; [root@wx03 mojo]# morbo test.pl
Server available at http://127.0.0.1:3000
Wide character in print at /root/mojo/test.pl line 10.
测试更健康
Wide character in print at /root/mojo/test.pl line 19, <LOG1> line 1.
$x is 验证
$d is 验证
1-------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为813231,本验证码30分钟内有效。 to phoneNo:18072722237 succeed! 2--------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的验证码为813231,本验证码30分钟内有效。 to phoneNo:18072722237 succeed! Wide character in print at /root/mojo/test.pl line 19, <LOG1> line 3.
$x is 验证
$d is 验证
1-------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的813231,本30分钟内有效。 to phoneNo:18072722237 succeed! Wide character in print at /root/mojo/test.pl line 19, <LOG1> line 4.
$x is 验证
$d is 验证
1-------$str is 2016-04-22 11:02:01,259 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:您的813231,本30分钟内有效。 to phoneNo:18072722237 succeed! 此时$d和$x都正常显示 [root@wx03 mojo]# cat c1.pl
use Encode;
my $x='验证';
print "\$x is $x\n";
my $d=encode_utf8('验证');
print "\$d is $d\n";
[root@wx03 mojo]# perl c1.pl
$x is 验证
$d is 验证 说明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. 405 HTTP method GET is not supported by this URL

    孙鑫java web开发详解P285里面提交Get网站弹出提示405 HTTP method GET is not supported by this URL 原因父类doGet()方法未覆盖. 应写 ...

  2. Hadoop Security Authentication Terminology --Kerberos

    Hadoop Security Authentication Terminology --Kerberos What is kinit? Kinit -  obtain and cache Kerbe ...

  3. CKEditor和CKFinder整合实现上传下载功能

    CKEditor与CKFinder整合并实现文件上传功能 事先说明:此整合的是java版本号的, 用到的有:jsp + ckeditor + ckfinder (没有servlet 及其他框架技术) ...

  4. DescribingDesign Patterns 描述设计模式

    DescribingDesign Patterns 描述设计模式 How do we describe design patterns?Graphical notations, while impor ...

  5. iOS 拍照保存到相册

    之前看了一些开源的代码,里面有一个功能,就是将图片下载到相册,仔细看了其中的代码,只有很简单的一句话,并且保存过后,还可以判断是否保存成功. 如下代码所示, 点击按钮,将self.imageView上 ...

  6. c语言中malloc realloc 和calloc的联系与区别

    (1)C语言跟内存分配方式 <1>从静态存储区域分配.       内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在.例如全局变量.static变量.<2> ...

  7. 部署ASP.NET MVC项目

    目标:了解部署过程,掌握部署中出现问题该如何处理. 部署网站往往是一件麻烦事,因为在安装部署的过程中,经常有许多步骤要运行,对于许多不太熟悉IIS/SQL的新手来说,部署网站编程一件非常困难且危险的事 ...

  8. 字符串如何判断null.

    转http://blog.sina.com.cn/s/blog_48cd37140101awgq.html Java中判断String不为空的问题 一.判断一个字符串str不为空的方法有: 1. st ...

  9. ASP.NET MVC 5 学习教程:通过控制器访问模型的数据

    原文 ASP.NET MVC 5 学习教程:通过控制器访问模型的数据 起飞网 ASP.NET MVC 5 学习教程目录: 添加控制器 添加视图 修改视图和布局页 控制器传递数据给视图 添加模型 创建连 ...

  10. 基于visual Studio2013解决C语言竞赛题之0419误差控制

       题目 解决代码及点评 /************************************************************************/ /* 19 ...