From owner-freebsd-questions@FreeBSD.ORG Wed May 13 17:10:36 2009 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A7962106566B for ; Wed, 13 May 2009 17:10:36 +0000 (UTC) (envelope-from niteshadez@gmail.com) Received: from mail-ew0-f159.google.com (mail-ew0-f159.google.com [209.85.219.159]) by mx1.freebsd.org (Postfix) with ESMTP id 316B08FC0A for ; Wed, 13 May 2009 17:10:33 +0000 (UTC) (envelope-from niteshadez@gmail.com) Received: by ewy3 with SMTP id 3so913329ewy.43 for ; Wed, 13 May 2009 10:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=akfTVxBaSEkXe+NvQrsie40gJRvnU6vo/lVFDl3m9W0=; b=a3B9q+HKy9kQ7nI4toG8DtuntMfi+uQDiNka9/AKoS6kbLtSgwwfkKxokrYynqYl49 kzpW1aBFdpQRCU0IrkmdGmHgX3zaTPkwtwzopalcG3rpO7Nt901BaEBKsaX4aj1eBlis X2oD86ATldM7KW2HGNHjK82m3pPfhIW5D547Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=c07KcjLWmtaZp9hjbQKQijMUTov7kUszCJ94/L3q8kx4yZ5Td9aLbWA9lbrnI3QmJy ga8+Uwpr3A282egcTOCmAJoEf7nk3hx4TN3y4qbED6NTcJsO0RpUek22C9GcXcmjaYt8 yhBA/8FikIqJTyJCdiL+thNHm+6EgSpje0HKc= MIME-Version: 1.0 Received: by 10.216.26.202 with SMTP id c52mr518182wea.98.1242233146550; Wed, 13 May 2009 09:45:46 -0700 (PDT) In-Reply-To: References: Date: Wed, 13 May 2009 09:45:46 -0700 Message-ID: <14b7230a0905130945r4142cde4p2a2ac156ff378ba6@mail.gmail.com> From: milk To: Tsu-Fan Cheng Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: FreeBSD Subject: Re: How to compare two arrays by using perl script? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2009 17:10:37 -0000 On Tue, May 12, 2009 at 11:05 AM, Tsu-Fan Cheng wrote: > I have two arrays, each has two columns (so its A1, B1 and A2, B2). As > are the positions while Bs are the values. I need to get the ratio > between B1 and B2 if their As are the same or close to each other > within a certain distance. Well, You can either compare it by hand or use a module. Use search.cpan.org to find modules that might be useful. A search for 'Arrays' brought me Set::Array which as the methods for at, length, intersection, and union. You can use length and union to find out how many elements in each array are different. If you want to know how 'close' each A is to each other, you probably need to compare each element in each manually. -- milki