in reply to data structure question

Use an object-oriented approach. Group your variables into related entities, define them as members of some object and then either define your subroutines as methods of these objects or write subroutines that accept these objects as parameters.