Update3: If you like this posting please don\'t upvote me but upvote the genius answer by DVK below.
Update3:
I have the following subroutines:<
Another (maybe simpler) way out is declare variables as "our" instead of "my"
So,
our %marked;
instead of
my %marked;
etc.