perl mojo 处理文本
来源:互联网 发布:九本女王升级数据2017 编辑:程序博客网 时间:2024/05/25 18:10
1.关闭utf8centos6.5:/root#cat t2.pl use Mojolicious::Lite; use JSON qw/encode_json decode_json/; use Encode; no strict; no utf8;use JSON; use Data::Dumper; # /foo?user=sri get '/admin/api/menu' => sub { my $c = shift; 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! if ($_ =~ /([0-9]{4}-[0-9]{1,2}-[0-9]{2}\s+[0-9]{2}:[0-9]{2}:[0-9]{2}.*?)\s+(.*?Send message:)\s*(.*?)(to\s+phoneNo:\s*[0-9]{11}).*/){ $a1=$1; $a2=$2; $a3=$3; $a4=$4; print "\$a1 is $a1\n"; print "\$a2 is $a2\n"; print "\$a3 is $a3\n"; print "\$a4 is $a4\n"; close LOG1; print "length\$a3--------------\n"; print length($a3); print "\n"; print "--------------\n"; my $a5="测试更健康"; print "length\$a5--------------\n"; print length($a5); print "\n"; print "--------------\n"; $c->render(text => "$a5" ); }; };}; app->start;centos6.5:/root#cat 11.out 2016-03-09 09:35:12,380 INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:验证to phoneNo:18072722237 succeed! centos6.5:/root#[root@yun-bak ~]# curl http://192.168.11.185:3000/admin/api/menuæµè¯æ´å¥åº·[root@yun-bak ~]# 此时curl 返回乱码centos6.5:/root#cat t2.pl use Mojolicious::Lite; use JSON qw/encode_json decode_json/; use Encode; no strict; no utf8;use JSON; use Data::Dumper; # /foo?user=sri get '/admin/api/menu' => sub { my $c = shift; 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! if ($_ =~ /([0-9]{4}-[0-9]{1,2}-[0-9]{2}\s+[0-9]{2}:[0-9]{2}:[0-9]{2}.*?)\s+(.*?Send message:)\s*(.*?)(to\s+phoneNo:\s*[0-9]{11}).*/){ $a1=$1; $a2=$2; $a3=$3; $a4=$4; print "\$a1 is $a1\n"; print "\$a2 is $a2\n"; print "\$a3 is $a3\n"; print "\$a4 is $a4\n"; close LOG1; print "length\$a3--------------\n"; print length($a3); print "\n"; print "--------------\n"; my $a5=decode_utf8("测试更健康"); print "length\$a5--------------\n"; print length($a5); print "\n"; print "--------------\n"; $c->render(text => "$a5" ); }; };}; app->start;centos6.5:/root#morbo t2.pl Server available at http://127.0.0.1:3000[Sun Mar 12 16:10:01 2017] [debug] GET "/admin/api/menu"[Sun Mar 12 16:10:01 2017] [debug] Routing to a callback$a1 is 2016-03-09 09:35:12,380$a2 is INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:$a3 is 验证$a4 is to phoneNo:18072722237length$a3--------------6--------------length$a5--------------5--------------[Sun Mar 12 16:10:01 2017] [debug] 200 OK (0.00105s, 952.381/s)readline() on closed filehandle LOG1 at /root/t2.pl line 15.[root@yun-bak ~]# curl http://192.168.11.185:3000/admin/api/menu测试更健康[root@yun-bak ~]# 1.开启utf8centos6.5:/root#cat t2.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; 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! if ($_ =~ /([0-9]{4}-[0-9]{1,2}-[0-9]{2}\s+[0-9]{2}:[0-9]{2}:[0-9]{2}.*?)\s+(.*?Send message:)\s*(.*?)(to\s+phoneNo:\s*[0-9]{11}).*/){ $a1=$1; $a2=$2; $a3=$3; $a4=$4; print "\$a1 is $a1\n"; print "\$a2 is $a2\n"; print "\$a3 is $a3\n"; print "\$a4 is $a4\n"; close LOG1; print "length\$a3--------------\n"; print length($a3); print "\n"; print "--------------\n"; my $a5="测试更健康"; print "length\$a5--------------\n"; print length($a5); print "\n"; print "--------------\n"; $c->render(text => "$a5" ); }; };}; app->start;centos6.5:/root#morbo t2.pl Server available at http://127.0.0.1:3000[Sun Mar 12 16:12:06 2017] [debug] GET "/admin/api/menu"[Sun Mar 12 16:12:06 2017] [debug] Routing to a callback$a1 is 2016-03-09 09:35:12,380$a2 is INFO com.zjzc.thirdparty.sms.SMSUtils - Send message:$a3 is 验证$a4 is to phoneNo:18072722237length$a3--------------6--------------length$a5--------------5--------------[Sun Mar 12 16:12:06 2017] [debug] 200 OK (0.001204s, 830.565/s)readline() on closed filehandle LOG1 at /root/t2.pl line 14.[root@yun-bak ~]# curl http://192.168.11.185:3000/admin/api/menu测试更健康[root@yun-bak ~]#
0 0
- perl mojo 处理文本
- perl mojo 编码
- perl 文本处理
- perl 处理文本
- 基于Mojo的perl爬虫
- perl文本处理总结[2]
- 一个Perl文本处理实例
- perl处理文本经验积累
- mojo 编码处理
- perl mojo use utf8 和no utf8
- perl mojo 短信接口自动识别编码
- perl处理文本经验积累(不断更新中)
- linux下perl处理文本---使用hash处理
- perl文本
- Perl与Python处理文本数值的一个比较
- Perl语言学习笔记 9 正则表达式处理文本
- Perl 文本预处理
- Perl文本替换命令
- acm书中题目 o-15
- 201个核心Java面试问题汇总(1)
- java基本编程
- json测试
- leetcode 336. Palindrome Pairs
- perl mojo 处理文本
- word2vec代码解读
- C++的STL的binary_search()和includes()
- Google官方支持的MVVM架构框架Data Binding使用入门
- 【React Native开发】
- ProteusMCU仿真
- Django-模型表单
- [java 线程] Java内存模型深度解读
- 命名数据网络(NDN)与TCP/IP网络