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);
}
}
$k=1;
foreach my $t (@other_url){
print "$k:$t\n";
$k++;
}
页:
[1]