Based on some things in your post, I'm assuming that your doing some GUI work. Also, since some of the syntax doesn't look quite like what I remember from Win32::GUI, I'm assuming that you're using Tk or some other GUI module.
Going off of those assumptions, here's the concept of what I've done using Win32::GUI. If you're using something else, you should still be able to apply the concepts with the module(s) that you're using.
- Create a textfield. Make it read only if you don't want the user to modify it directly.
- Create a browse button. When it's clicked, do the following:
- Pop up a folder browser window.
- If the pop up is canceled, do nothing.
- If a file/directory is selected, update the textfield to display the path selected.
This allows for the selected path to be accessible by retrieving the text value of the textfield. If for some reason you can't use a textfield (or don't want to use one), then I'd agree with previous reply about using global variables.