How to compare two arrays by using perl script?

milk niteshadez at gmail.com
Wed May 13 17:10:37 UTC 2009


On Tue, May 12, 2009 at 11:05 AM, Tsu-Fan Cheng <tfcheng at gmail.com> 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


More information about the freebsd-questions mailing list