Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

formatting perl output. please help

Status
Not open for further replies.

m4trix

Vendor
Jul 31, 2002
84
CA
one part of a script that I wrote has to output information from a database in a nicely formatted table, that looks different depending on the data that is to be displayed. I have no problem doing this, & it works fine. Here's the problem though. I have a main menu, and when the user selects the option to output the data to the screen it calls a subroutine that does that. The first time it runs, it works perfectly, then returns them to the main menu. if they run the subroutine again though, the output it messed up.
For example, the FORMATHANDLE_TOP isn't displayed the second time, and other things like that. Any ideas?
All the variables used in the subroutine are local (I think... I initialized all of them within the brackets of a "my" function)
here is some "sample" (i've edited it, made it thinner, cut it down, etc) output:

Code:
##################################
INSERT MAIN MENU STUFF HERE....
call the subroutine:
##################################

                       -=DATA=-

 Name          Side Room# | Target Name   Side Room#
--------------------------+-------------------------
 Bernie Walker    B   323 | biggie steve     B   125
 Billy Bob        B   124 | Jimmie rims      B   036
 Chris Nasher     A   135 | silly Heade      B   222
 Greg Somethin    B   352 | billy bob        A   324
 test name        A   323 | need more        B   325
 chad buthead     B   232 | Super Man        B   324
 hot potato       B   823 | jason mohawk     A   082
Press Enter to continue . . .
 mark delaney     B   337 | Someone Else     A   126
 need more        B   325 | hulo gorge       A   323
 steve long       B   036 | need a name      A   489

Press Enter to return to the main menu...

##################################
INSERT MAIN MENU STUFF HERE....
recall the subroutine:
##################################

 Bernie Walker    B   323 | biggie steve     B   125
 Billy Bob        B   124 | Jimmie rims      B   036
 Chris Nasher     A   135 | silly Heade      B   222
 Greg Somethin    B   352 | billy bob        A   324
 test name        A   323 | need more        B   325
 chad buthead     B   232 | Super Man        B   324
 hot potato       B   823 | jason mohawk     A   082
Press Enter to continue . . .
 mark delaney     B   337 | Someone Else     A   126
 need more        B   325 | hulo gorge       A   323
 steve long       B   036 | need a name      A   489
                  B       |                  B
                  B       |                  B
                  B       |                  B
                  B       |                  B
                  B       |                  B
                  B       |                  B
                  B       |                  B
Š
                       -=DATA=-

 Name          Side Room# | Target Name   Side Room#
--------------------------+-------------------------
                  B       |                  B
                  B       |                  B
                  B       |                  B
                  B       |                  B
                  B       |                  B
Press Enter to continue . . .

#####################################
Here it scrolls lines and lines of (separated by prompts every 20 lines):

                  B       |                  B

occasionally throwing in a:

                       -=DATA=-

 Name          Side Room# | Target Name   Side Room#
--------------------------+-------------------------
#######################################
 
1. You need to reset your format variables, as the second time through, the formatter thinks it is in the middle of a page, hence no format header text is shown.
2. Looks like your variable used in the main format body is getting garbled.
Like johv20 says, we need to see some code.
Cheers, Neil :)

 
To print the FORMATHANDLE_TOP again, like toolkit said, you need to reset the FORMAT_LINES_LEFT variable, $-, by setting it to zero before the write statement or at the beginning of the subroutine (depending on how your code is structured).
Code:
$- = 0;
# some code
write;
If this doesn't fix the garbled out put then you will have to post your code.

jaa
 
Hmm.. still having problems.. but the code is really long, and you'd probably have a tough time deciphering it. the subroutine using the formatted output is about 100 lines long, the whole script is about 1500.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top