in reply to Re: Re: Array of arrays used within object
in thread Array of arrays used within object

In the interests of getting some data, I now have a crude substitute for the ideal code (I'll work on that when deadlines are less pressing). It's like this:

package msatminer; sub zap { @nreg = (); } # rest of package essentially the same as posted above...

Thus, calling a “msatminer::zap” before opening each genome file, then running the other methods on the starts and stops, and saving the results before the next “zap” I can at least get valid results out.

However, if this is somehow very, very naughty in a way I haven't realised, then please tell me ;-)

Thanks.

Replies are listed 'Best First'.
Re: Re: Re: Re: Array of arrays used within object - crude substitute
by esh (Pilgrim) on Aug 08, 2003 at 01:36 UTC
    It sounds to me like you understand the problems created by the global variable and the right approach you would like to take in an ideal world--converting the code to an OO design.

    You're just running into the normal problems in trying to figure out how to design and implement objects when you haven't done it a lot before.

    I don't think I can solve the problems you're running into given the information I have at hand, but I would encourage you to take the time to learn Perl OO when you get past the current deadline crunch. Designing the code cleanly from the start helps alleviate a lot of roadblocks you might run into otherwise.

    A simpler step to avoid global variables than converting your code completely to OO, might be to learn about Perl references and pass the big arrays around by reference to your different subroutines.