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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PERL Format - format name versus filehandle

Status
Not open for further replies.

dneid

Technical User
Sep 1, 2007
3
US
Hey, All,
Well, I am stumped. I am trying to get a set of formats working in a script. I want to have a header (_TOP) and then the body. Well, I can not even get the header working correctly.

Here is what I started with(with lots of calculation missing):

open (TMP_OUT_FILE, ">optimize_report.tmp") || die("File is not open");

write;

format TMP_FILE_OUT =
Simulation Measurement(s) data:

| SIM1 Measurement | SIM2 Measurement | Difference |
+------------------+------------------+--------------+
.

This writes to STDOUT just fine. Now, when I change write to write to the filehandle (write(TMP_OUT_FILE);), I get the following error:
Undefined format "TMP_OUT_FILE" called at ./opt_capChar_ratio line 158

I have tried several different things including changing the format name to TMP_OUT_FILE_TOP. I tried setting $~ = TMP_OUT_FILE_TOP and $~ = TMP_OUT_FILE. This one has really got me stumped!!


Any help with this would be appreciated.

Thanks,
Dale

Perl Version Info: This is perl, v5.8.5 built for x86_64-linux-thread-multi
 
print TMP_FILE_OUT "Blah BLah BLah Blah\n";



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
use the select function to select the filehandle:

Code:
(all your code here)
select(TMP_OUT_FILE);
write;
select(something else if need be);

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top