Perl 对json的过滤脚本

最近在写一个web应用,其中接触到json过滤,根据数据的类型写出这个脚本。
本来准备使用第三方库的,可是网速太卡,所以。。。。

#!/usr/bin/perl

$tmp=<>;

if($tmp=~m#{(.*)}#){
     $list=$1;
     @tmp=split(/,/,$list);
}
@tmp_url= keys %{ {map {$_ => 1} @tmp} };
while(<@tmp_url>){
     if($_=~m#status:(.*)#){
          if($1 != 'Success'){
                last;
          }
     }
     if($_=~m#^\[(.*)#){
          push(@other_url,$1);
     }
     if($_=~m#domainArray:\[\[#){
          @key=split(/\[/,$_);
          push(@other_url,$key[2]);
     }
}
$k=1;
foreach my $t (@other_url){
     
     print "$k:$t\n";
     $k++;
}

 

posted @ 2013-04-11 01:03  墨迹哥's  阅读(319)  评论(0编辑  收藏  举报