in reply to Error msg "requires explicit package name"

Lucky you - you found one of the sloppy behaviors that use strict was made to catch! You might want to change the $counter = 0 line so it reads:

my $counter = 0;

See, strict makes sure that you are only using variable names you know about. Every variable must be declared with my, our, or use vars (LIST).