in reply to Missing $ on loop variable at measurements2.pl line 69.

I think you'll find it's the:

for my ($counter=0;$counter<9;$counter++)
construct (which you have two of.) You either want to move the move the my inside the brackets like:
for (my $counter=0;$counter<9;$counter++)
Or even better use the more perl-ish
foreach my $counter (0 .. 8)

/J\