CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
cannot reset the line counter variable $-

 



stevep
New User

Jul 6, 2005, 7:07 PM

Post #1 of 1 (823 views)
cannot reset the line counter variable $- Can't Post

I am trying to use a format string with header. I need to start a new page header in the middle of the generated output. I have read elsewhere that I only need to set the variable $- to 0 via $-=0;

It does not cause a new report header to be started.

Here is a sample of the problem:

#!/usr/bin/perl -w
format RPT_TOP =
REPORT HEADER
.
format RPT =
@<<<<<<<<<<<<
$f
.

open RPT, ">/tmp/testout" || die "cannot open /tmp/testout";

for ($i = 0; $i<25 ; $i++)
{
$f = sprintf("i line %d", $i);
write RPT;
}
$- = 0;
for ($j = 0; $j<25 ; $j++)
{
$f = sprintf("j line %d", $j);
write RPT;
}

close (RPT);

------------


What I get is:
REPORT HEADER
i line 0
i line 1
......
i line 24
j line 0
j line 1
j line 24


What I want is:
REPORT HEADER
i line 0
i line 1
....
i line 24
REPORT HEADER
j line 0
j line 1
.....
j line 24

I am assigning $- to 0 in the middle of the two for loops?

Why can't I get a report header in the middle of the output?

Thanks for your help.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives