I ran into this problem with global variables about two weeks ago when I was trying to write a nice little program to run sql queries to any database connection (as opposed to using sqlplus for oracle isql_w for ms-sql etc...). It does seem contradictory to basic programming to use global variables for most of your code. I read all the replies and realized that I'm still a newbie when it comes to programming especially in PERL, I have no idea what a singleton is.
What I did was create the windows in separate subroutines and then used semiprivate variables using local instead of my. Since the window was created in the subroutine all the variables are only defined in the scope of the that subroutine and any other subroutines called from it, such as Window_Click(). Once the program exits that subroutine all the variables are dropped so I don't waste any memory which I would if they were global and I can use the variables with the same name in any other subroutine. Also I think that the use of semiprivate variables will not cause any warning or errors if you have "use strict". I'm not sure though. This might not be the best way of getting around the problem but it works for me and my limited skills so I thought I would mention it. If I'm wrong on any of this or have made things worse with my approach let me know. I will be happy to post my code of the program I am working on if anyone wants to see it, just remember I'm still working on it so it's not perfect and I still have to make several changes (it's only been two weeks) but it will show you what I am doing. Joe Mark Wilkinson <[EMAIL PROTECTED]>@lists.sourceforge.net on 11/03/2001 07:31:12 PM Please respond to [EMAIL PROTECTED] Sent by: [EMAIL PROTECTED] To: cc: perl-win32-gui-users@lists.sourceforge.net (bcc: Joseph Vieira/DMR/CA) Subject: [perl-win32-gui-users] ACK!! Sputter Cough... say it isn't so! Someone please... save me before I choke! Please say it isn't so!! Tonight I really started to build a serious heavy-duty Win32::GUI application, and I immediately hit a wall: Is it really not possible to (usefully) program in Win32::GUI while under "use strict"?!? I say this because there appears to be **nothing** passed to the event-handling subroutines - not even a reference to the widget itself! This, IMHO, is absolutely insane! That means that all of my widget refs, and every variable that is required in the event-handling subroutines, have to be global variables... which would make comp-sci professors roll over in their future graves... a "good" program should never need to have a *single* global variable, let alone *every* variable being global. If even the widget ref was sent to the event-handler I could attach the subroutine's required variables to its hash, but as things are it seems to break every rule I know about "good" programming style. I must be missing something... Please, someone, tell me that it doesn't really work this way... Mark _______________________________________________ Perl-Win32-GUI-Users mailing list Perl-Win32-GUI-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users