in reply to $FORMAT_LINES_LEFT question.

I guess no one really has an answer for this so I'll have a go ...

I think that $FORMAT_LINES_LEFT is only relevant if you happen to specify the FILEHANDLE_TOP format for your handle. In your case, you need STDOUT_TOP. That's why it wraps to 999999 rather than 60. In any case this feels like a bug.

And I don't think that $FORMAT_LINES_LEFT actually starts at zero. I think it starts life as undefined which, of course, numifies to 0. Perl probably checks for the undefinedness of this variable so that you can have the first page headerless and longer than all of the rest if you want to. Then from that point on it sets $FORMAT_LINES_LEFT = undef if $FORMAT_LINES_LEFT < 1; because I think the undefined value in $FORMAT_LINES_LEFT is what triggers the output of the header (FILEHANDLE_TOP) and causes perl to set $FORMAT_LINES_LEFT = $FORMAT_LINES_PER_PAGE -number of lines in header - 1 (The -1 is for the line just printed (the first line))

Caveat lector of course as I'm just guessing. It's been many many many years since I've actually used formats. (I believe perl4 was the perl du jour when last I used them). I'm sure there's some simpler explanation, but since I can't think of it, this will give someone else target good target practice :-)

Replies are listed 'Best First'.
Re: Re: $FORMAT_LINES_LEFT question.
by ysth (Canon) on Feb 01, 2004 at 04:44 UTC
    $- and $= are magically bound to fields in the currently selected IO handle, and can only be integers. Watch:
    $ perl -we'$= = "123 abc"; print $=' Argument "123 abc" isn't numeric in scalar assignment at -e line 1. 123 $ perl -we'$= = undef; print $-' Use of uninitialized value in scalar assignment at -e line 1. 0
    Whatever you feed them is converted to an integer (with a warning, if appropriate) as it is stored. (In the case of $-, it also is made 0 if it was negative.)

    One of my all time favorite warning messages:

    $ perl -we'undef $=; print $-' Use of uninitialized value in undef operator at -e line 1. 0