奇科電腦 回奇科電腦首頁奇科電腦LPI課程資訊奇科電腦Embedded課程資訊奇科電腦Cisco課程資訊奇科電腦Programming課程資訊奇科電腦Smartphone App課程資訊
Tech Tips19  How to compare two arrays in Perl?

Author: Ben|Date: 2009/05/16|Back to Tech Tips

Two arrays has two fields, A1 B1 and A2 B2, respectively, where A is coordination and B is A’s value. Please calculate the proportion of B1 and B2 if A1 and A2 is the same or similar:

#!/usr/bin/perl -w

my @data = qw( 1 3 );
my @data1 = qw( 2 10 );

$coor_diff_allow = 1;

if ( abs( $data[ 0 ] - $data1[ 0 ] ) <= $coor_diff_allow )
{
print "\nThe ratio of values is : ", $data[1]/$data1[1] ,"\n";
exit 1;
}
else
{
print "The coordination is not even close.\n";
exit 1;
}


Best Browse: 1024x768 Copyright 2010 GeeGo Systems, Ltd.
service@geego.com.tw|DL: 0800-296-296|3F., No.60, Zhulun St., Zhongshan Dist., Taipei City 104, Taiwan (R.O.C.)|02-2711-6373