Perl数据处理程序

返回

DB输入数据的前处理(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中原有行列项目 @b = (2,3,5,7,9); # 新的enq1的行列项目 # @union:两个行列的所有项目 # @isect:两个行列都有的共通项目 # @diff:DB新增加项目 @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
戻る