Ok, I'm writing an apxl to html converter and I have one little problem: I need to open a filehandle in one sub, use it in several others, and then close it in a different sub yet. I'd pass it as a parameter, but all the subs are actually called by XML::Parser, so I don't get to choose the parameter list. Therefore I'm trying to keep it in a 'global' (package-level) variable, but I can't seem to get it to work. ;-)
Here's what I'm trying at the moment: -------------
my $curFile; # The current output file. my $html; # The HTML Stream.
# Some code....
# The start of a slide.
sub slide
{
# Open/create the file.
$slideNum++; # Incriment the slide number.
open CURFILE, "> slide$slideNum.html" or warn "Could not open slide$slideNum.html: $!";
$curFile = \*CURFILE;
$html = new HTML::Stream($curFile);
# More code... (All from HTML::Stream) }
# The end of a slide. sub slide_ { # Closing code... # Close the file. close $curFile; }
-----------
This goes through with no warnings or errors, but the code in slide_() does not have access to the file opened in slide(). (It does get run, I tested that.) Anyone have any ideas (other than re-opening it in every sub, which I could probably do as a last resort...)?
Daniel T. Staal
--------------------------------------------------------------- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. ---------------------------------------------------------------
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]