Abhijit Shylanath said: > Greets, all. This is my first post here... I'm a seasoned C/C++ > programmer, > and recently started learning perl... it's going along well, and as an > exercise, I've completely Perl'ed my webpage. I'm still a little dizzy > because of the different directions it's pulling me towards, but it's fun > anyway. Chaos always is :-)
I suspect that the different directions in which Perl is pulling you will actually help you improve your C/C++ code, whilst at the same time frustrating you that C/C++ makes everything so difficult ;-) > #ifdef INQUISITIVE_CHAR > > I'm keeping an array of tips (read from a file) in memory. At strategic > (at > least I think so) locations in the file, a random tip is displayed. Once > it > is, it has to be marked as used. Currently, I'm doing this: > > # Tip is done; remove it > $tips[$tip_num] = $tips[$num_tips - 1]; > undef $tips[$num_tips - 1]; > --$num_tips; > > Am I doing it cleanly? > Should I use $#tips instead of a separate count variable (as I've done), > and > will decrementing $#tips actually reduce the size of the array in memory? So you are returning and removing the last element of the array. In Perl this is done with the pop() function. $tips[$tip_num] = pop @tips; But is that right? You are writing into the same array you are reading from? As to your specific questions, the answers are probably yes and yes, or at least yes and it-depends-what-you-mean. But I can't help feeling that copying between (or within) arrays is probably not an optimal solution. > #endif // INQUISITIVE_CHAR -- Paul Johnson - [EMAIL PROTECTED] http://www.pjcj.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]