Showing results for 
Search instead for 
Did you mean: 

Perl, write format vars $= and $- problems,

Go to solution
Occasional Advisor

Perl, write format vars $= and $- problems,


I'm using perl program with < write FORMAT> to generate some reports and having problems to to deal with page break and line-per-page-no.
I can't manipulate $= and $- (which are global?), no matter what I do after wanted page break (if break $- =0;) or how I set number of lines on page ($= = 33) I still have defaulted 60 lines per page and don't have wanted page breaks.

I tried to refer to them both as $= / $FORMAT_LINES_PER_PAGE, or $- / $FORMAT_LINES_LEFT ,
in fact if I let say $FORMAT_LINES_PER_PAGE =33, then $= still shows 60 . I have . I see that $- doesn't get changed
during the execution, it's alwayse = 0. and I see that var $% (page#) works just fine, get incremented by 1 after each 60 lines page break.

Appreciate your help, is any package I'm missing, I'm using most recent ActivePErl on Wxp. Final destination will be Linux box. In worst I can probably turn off auto write format_TOP? so I will switch to my local vars.
But dying to crack this puzzle what is wrong with this vars?


Please don't send me somewhere else from Perl, in my situation I don't have other choice.
Ralph Grothe
Honored Contributor

Re: Perl, write format vars $= and $- problems,

Hi Trent,

I haven't used Perl's formats for ages
so I would have to reiterate over it myself again.
Maybe you find an answer in "perldoc perlform"?

Btw. as for reassigning globals,
just localize them within a code block,
would this work?


local ${=}=20;

What I also remember when I worked with formats that within them you sometimes would have to use some arcane dereferencing on variables to access their value,


format NAME =
@{[$var1, $var2]}

But I my memory may misguide me here.

Madness, thy name is system administration