perl encode_utf8必须用在utf8环境
[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环境的更多相关文章
- encode_json 会对给定的Perl的数据结构转换为一个UTF-8 encoded, binary string.
use JSON qw/encode_json decode_json/ ; use Encode; my $data = [ { 'name' => 'Ken' , 'age' => 1 ...
- C、Shell、Perl基于Tomcat开发CGI程序环境配置
基于Tomcat7.0版本号配置CGI开发环境,步聚例如以下: 以我的Tomcat7安装文件夹为例:TOMCA_HOME = /Users/yangxin/Documents/devToos/java ...
- perl encode_utf8 和decode_utf8
encode_utf8 等于 $octets = encode_utf8($string); 这个字符串 在$string 在Perl的内部格式,返回结果是作为一个顺序的字节. 因为所有的可能的字符串 ...
- Eclipse 完全 设置UTF-8 环境
当开始一个新的Java项目时,最好将整个环境设置为UTF-8 一般通过如下几步来设置: 1: 设置工作空间的编码格式:Window -> Preferences -> General -& ...
- 理解perl的编码转换——utf8以及乱码
工作需要,闲暇之余,仔细研究了一下脚本乱码的问题 1. vim新建的文件 1)在linux命令行 vim命令建立的文件,如果内容中不出现中文,默认是ASCII.那么用notepad++打开的时候,就是 ...
- 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 ...
- perl use utf8
utf8 Perl编译 来启用/禁用 UTF-8(or UTF-EBCDIC) 在源代码里 简洁: use utf8; no utf8; # Convert the internal represen ...
- perl unload gbk oracle 数据库
perl unload gbk Oracle 数据库 use Encode; if ( $#ARGV < 0 ){ print "请输入一个文件\n"; exit(-1); ...
- 通过demo搞懂encode_utf8和decode_utf8
perl 编码问题: use utf8表示代码使用UTF-8写的 [root@wx03 0710]# cat a1.pl #use utf8; my $str='测试utf8字符集'; print $ ...
随机推荐
- JRebel 6 破解版及使用方法
最近更新到jrebel6.2.1了,我自己做了个技术分享的微信公众号(茶爸爸),有心的朋友可以来这里一起学习 云盘下载链接: http://pan.baidu.com/s/1bnGzMUF 配置: - ...
- 警惕 MySql 更新 sql 的 WHERE 从句中的 IN() 子查询时出现的陷阱
mer_stage 表有 216423 条记录,DDL: CREATE TABLE `mer_stage` ( `STAGE_ID` int(11) NOT NULL AUTO_INCREMENT, ...
- ASP.NET站点安全
<configuration> <appSettings/> <connectionStrings> <add name="MyBookShop&q ...
- reason: 'unable to dequeue a cell with identifier Cell
今天在cell重用的时候出现一下错误 reason: 'unable to dequeue a cell with identifier Cell - must register ...
- MacBook外接显示器设置方法(新手入门贴)
小屏幕的MacBook/MacBook Pro放在桌上长时间使用,眼睛比较累,而且,长时间低头看屏幕,易得颈椎病,绝对有损健康.配一台大屏幕的外置显示器不失为两全其美的好办法. 首先,得买一台中意的大 ...
- 如何设置ssh安全只允许用户从指定的IP登陆
原文链接: 如何设置ssh安全只允许用户从指定的IP登陆 由于开发上传文件需要 在服务器上开启 允许用户名和密码ssh登录.这样不太安全.百度后参考文章现在ssh用户名和密码登录的ip. 登录服务 ...
- [转]如何从MySQL官方Yum仓库安装MySQL5.6
参考博文: 如何从MySQL官方Yum仓库安装MySQL5.6 Centos 升级Mysql版本或者Yum安装Mysql5.6 2013年10月,MySQL开发团队正式宣布支持Yum仓库,这就意味着我 ...
- HDU 3925 Substring 【大数相减】
题目意思是,给你提供两个数字 a 和 b a 可以不断的往上加, 直到b 为其子串 问的是 a 最小加几? 显而易见,a 的数据范围给了10 ^100非常大,直接模拟肯定不行 那么就用 b 减去 a ...
- POJ 3047 Fibonacci
DEBUG很辛苦,且行, 且珍惜 原代码: ans[0][0] = (ans[0][0] * a[flag][0][0] + ans[0][1] * a[flag][1][0]) % 10000; a ...
- C#注册表
C#注册表情缘 记得当时刚接触C#的时候,喜欢编写各种小软件,而注册表系列和网络系列被当时的我认为大牛的必备技能.直到我研究注册表前一天我都感觉他是那么的高深. 今天正好有空,于是就研究了下注册表 ...