in reply to Can I do an "inner read"?

digger,

Apologies that I don't have time to completely review your code, but I noticed a few things upfront.

$end_chapter is initialized to 1 and always set to 1 by chapterize so that handleSeps will always get called on each line of input from the main loop.

In handleSeps $counter is initialized to zero and incremented only at %%BeginPageSetup, but in the same if clause if it hits 3, it is reset to 0. So, $counter never makes it past three, and handleSeps will only return at EOF.

Also, note that the first line of input (which is stored in $line) will never actually get printed to the output, as this only happens on the else clause of the main loop which is never hit.

Of course the real killer is the catch that <> only assigns to $_ in a while statement if it is the only thing inside the conditional. In the absence of that, and since $_ is not localized here, it will retain it's previous value -- The first line read from the file. This will be continously output (as $counter is not incremented) to your temp file.

If you are lucky enough that the first line of your input file contains %%BeginPageSetup or Output... then a slightly different string will be output to your temp file.

After that, the temp will grow as large as your filesystem permits (or until you hit ctrl-c)

Hope that helps....

Replies are listed 'Best First'.
Re: Re: Can I do an "inner read"?
by digger (Friar) on Mar 12, 2004 at 17:19 UTC
    Thanks for the analysis captain.

    I found the first problem shortly after posting.

    I found the second issue this morning when I was able to pick this little project up again.

    Issue number 3 was the "real killer" as you say. I put my solution together, and couldn't see the side effects of other errors while this issue remained. Once kappa pointed out the underlying problem, I was able to solve the other issues pretty quickly.

    Thanks again for taking the time to look at my code.
    digger