in reply to accessing values from multidimensional arrays

The arrays contained in @coords are actually array references (created using square brackets), so you should write:
my $coords = join ',', @{$coords[$goal]};
instead of:
my $coords = join ',', ${coords[$goal]};
In other words, you need to dereference your arrays.

Michele.