#!/usr/bin/perl -w use strict; use Algorithm::Cluster qw/distancematrix/; my $weight = [ 1,1 ]; my $data = [ [ 1.1, 1.2 ], [ 1.4, 1.3 ], [ 1.1, 1.5 ], [ 2.0, 1.5 ], [ 1.7, 1.9 ], [ 1.7, 1.9 ], [ 5.7, 5.9 ], [ 3.1, 3.3 ], [ 5.4, 5.3 ], [ 5.1, 5.5 ], [ 5.1, 5.2 ], ]; my $mask = [ [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], [ 1, 1 ], ]; #------------------ # Define the params we want to pass to distancematrix my %params = ( transpose => 0, dist => 'e', data => $data, mask => $mask, weight => $weight, ); #------------------ # Here is where we invoke the library function! # printf("Calculating the distance matrix\n"); my $matrix = distancematrix(%params); # #------------------ my $row; my $number; foreach $row (@{$matrix}) { foreach $number (@{$row}) { printf("%7.3f\t", $number); } printf("\n"); }