in reply to Question of scope

You might find one of these forms simpler (and shorter): sub { push @coords, @_[1,2] } or
sub { my (undef, $x, $y) = @_; push @coords, $x, $y; }

gav^