Perl數(shù)據(jù)處理程序
返回
DB輸入數(shù)據(jù)的前處理(test_array.pl)
# test_array.pl
use strict;
my(@a,@b,@union,@isect,@e,@diff,%count,%count2,$e,$n);
@a = (1,3,5,6,7,8,11,23); # DB中原有行列項(xiàng)目
@b = (2,3,5,7,9); # 新的enq1的行列項(xiàng)目
# @union:兩個(gè)行列的所有項(xiàng)目
# @isect:兩個(gè)行列都有的共通項(xiàng)目
# @diff:DB新增加項(xiàng)目
@union = @isect = @diff = ();
foreach $e (@a,@b) { $count{$e}++ }
@union = sort {$a<=>$b} keys %count;
print "a=@a\n";
print "b=@b\n";
print "union=@union\n";
foreach $e ( keys %count ) {
if ($count{$e} == 2 ) {
push @isect, $e;
$count2{$e}++;
}
}
for $n ( 0 .. $#b ) {
next if $count2{$b[$n]};
push @diff, $b[$n];
}
@isect = sort {$a<=>$b} @isect;
@diff = sort {$a<=>$b} @diff;
print "isect=@isect\n";
print "diff=@diff\n";
--------------------------
C:\database\perl>perl test_array.pl
a=1 3 5 6 7 8 11 23
b=2 3 5 7 9
union=1 2 3 5 6 7 8 9 11 23
isect=3 5 7
diff=2 9
戻る
卫辉市|
平远县|
营山县|
姚安县|
宜川县|
孙吴县|
呈贡县|
张家口市|
祁门县|
海盐县|
津南区|
行唐县|
三亚市|
天全县|
阿城市|
金平|
乡宁县|
卢氏县|
阳山县|
新龙县|
昌宁县|
英超|
台湾省|
漳平市|
牟定县|
教育|
永吉县|
江西省|
泾源县|
长子县|
新田县|
内黄县|
安溪县|
黄龙县|
大连市|
砚山县|
名山县|
邢台县|
大名县|
通辽市|
丰顺县|