zoukankan      html  css  js  c++  java
  • Mojo 返回一维和二维数组

    这种情况不断的网数组@arr2里放入数据,返回的内容为:
    
    这种情况是一维数组:
    
    while( $selStmt->fetch() ){
    print "$a1 is $a1
    ";
    print "$a2 is $a2
    ";
    print "$a3 is $a3
    ";
    push (@arr2, "$a1  $a2  $a3" );
      };
    
      $c->render(json =>  @arr2);
    };
    
    
    http://192.168.32.101:3000/api/auto_publish/publish_info?env=uat 返回结果:
    
    ["121.40.189.90  uat-frontend  uat","121.40.100.198  zjzc-hy-pre-01  uat","121.40.100.198  zjzc-hy-core-01  uat"]
    
    
    另外一种情况,返回二维数组:
    
    foreach (@arr){  
    ##2015-11-04 15:51:54,134 DEBUG com.zjzc.thirdparty.sms.SMSSendThread 
    
    ##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*(.*?)(tos+phoneNo:s*[0-9]{11}).*/){
    	
    	$a1=$1;
    	$a2=$2;
    	$a3=$3;
    	$a4=$4;
        
    	##微信是UTF-8字符集
    	
    	
    	my 	$endtime=strftime("%Y%m%d%H%M%S",localtime());
    	
    	my $d=encode_utf8('验证');
    	if ($a3 =~/$d/){ 
    	#$msg->reply("@$friend $a1-$a3-$a4");
    	$a3=decode_utf8("$a3");
    	##encode("utf8",decode("gbk","格式为:中均/温金 客户手机号"))
    	 #@content=($a1,$a3,$a4);
    	 my @content=("$a1","$a3","$a4");
    	 my $href= @content;
    	 push (@arr_out ,$href);
                      }
    				                              };
               };

  • 相关阅读:
    HDU5873
    HDU5874
    HDU1565(状态压缩dp)
    POJ2774(二分+哈希)
    HDU4474
    HDU2602(背包)
    单链表
    POJ2503(hash)
    POJ1200(hash)
    顺序表
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350821.html
Copyright © 2011-2022 走看看