[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. apache加载php模块失败

    LoadModule php5_module "G:/php54/php5apache2_2.dll" apache2 conf加入这个之后无法加载 解决办法 在这句之前加入PHP ...

  2. float与position

    使用float会使块级元素的宽高表现为包裹内容(在不设定宽高的情况下)  这是当然的  我们使用float就是使几个div排在一行 当然不可能在宽度上撑满父元素啦  至于高度 不论有没有float 高 ...

  3. 如何修改Sublime 侧边栏Sidebar的颜色

    参考自:http://blog.csdn.net/a497393102/article/details/10563791 首先要找到 Default.sublime-theme 文件, 点击 subl ...

  4. VS2010/MFC对话框三:创建对话框类和添加控件变量

    创建对话框类和添加控件变量 前两讲中讲解了如何创建对话框资源.创建好对话框资源后要做的就是生成对话框类了.生成对话框类主要包括新建对话框类.添加控件变量和控件的消息处理函数等. 例程Addition是 ...

  5. 1354 - IP Checking(水题)

    1354 - IP Checking   PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 MB An I ...

  6. git 使用过程(三、文件的添加 修改)

    1.库中添加文件 在目录下新建一个文件 如 testfile.txt .输入命令:① git add testfile.txt  ②git commit -m "这里是你提交的说明" ...

  7. 在主函数中提示用户输入用户名和密码。另写一方法来判断用户输入是否正确。该方法分别返回一个bool类型的登录结果和和一个string类型的登录信息。如登录成功,返回true及“登录成功”,若登录失败则返回false及“用户名错误”或“密码错误”(使用out参数)

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  8. NHibernate变的简单

    前言 这篇文章出自于我尝试学习使用Nhiberbnate的挫败感.我发现好像Nhibernate全部的介绍材料不是很模糊就是太详细.我所需要的就是一个简单直接的教程,能让我尽快对NHibernate熟 ...

  9. django cookie

    设置:auth.login(request, user)                response = HttpResponseRedirect(reverse("index" ...

  10. 编写存储过程导出oracle表数据到多个文本文件

    1.测试表和数据: create table test(id )); begin .. loop insert into test values(k,'test'||k); end loop; end ...