|Just another Perl shrine|
Re: Open file issuesby davorg (Chancellor)
|on Aug 18, 2004 at 09:55 UTC||Need Help??|
If you were running with "use warnings" then Perl would have told you what the problem is. Filehandles aren't first-class variables in Perl so you can't just return a filehandle from a function and assign it to a variable like that. You're actually using the same filehandle (FILE) for both files - which is why you can't use it after you've closed the first filehandle.
You can get round this by using lexical filehandles.
Some of your logic is a bit scary, so I haven't changed too much. You might need to check it carefully.
"The first rule of Perl club is you do not talk about