Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
General
cancel
Showing results for 
Search instead for 
Did you mean: 

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

SOLVED
Go to solution
JianW
Occasional Advisor

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

Hi,

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?

Tx

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

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?

e.g.

{
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,
like

e.g.

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

But I my memory may misguide me here.

Madness, thy name is system administration