Rather than calling open directly it would probably be better to have a routine for opening files as well as one for closing them. It would maintain a HoH, %openFiles perhaps, keyed by file name or stringified handle, that would have a key/value pair added when a file was opened. The value would be a hash reference with key/value pairs for file name, file handle and a flag for whether or not to unlink. The HoH would be iterated over by the clean-up routine to close and optionally unlink any open files. I think this would be preferable to your scheme, where you have a different number of arguments in calls to quit() depending on how far you have reached in the script. By the way, use quit( ... ) rather than &quit( ... ) unless you want the specific behaviour that the ampersand dictates.
I hope these ramblings are helpful. I'm sorry I haven't given a code example but it's way past my bedtime!
Cheers,
JohnGG
In reply to Re: Trouble Passing File Handles
by johngg
in thread Trouble Passing File Handles
by Photius
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |