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

Writing to a file

Status
Not open for further replies.

Loon

Programmer
May 24, 2000
100
GB
This might not be as tricky as I think. I've written a tracing module which I am now using in another project. The tracing module opens a local file descriptor and file and then writes tracing information to the file whenever the TRACING::TRACE() function is called in the 'other' project. <br><br>However, I have noticed problems, especially when reading from STDIN, that traced strings are not getting written to the trace file (until the program stops or at certain parts of the script). <br><br>Should I be flushing the strings written to the tracing file descriptor with every call? If so what would people suggest as the best method? I would like to keep the tracing module as small, fast and simple as possible for maintainence reasons.<br><br>Cheers!<br>Loon
 
maybe????? you could set your print buffer to autoflush........like <br><FONT FACE=monospace><br>$¦ = 1;<br></font><br><br>This will effectively set the print buffer size to zero, which will force immediate output of anything printed and will also cause some decrease in efficiency which would be delivered by using a print buffer.<br><br>'hope this helps... <p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo
 
Thanks! I'll try that, maybe someone can also help me out <br>with the error message I am getting...<br><br>Module 1 uses the TRACING module<br>My program uses Module 1.....<br><br>However, if I declare module 1 thus:<br><br><FONT FACE=monospace>use TRACING;<br>package module_1;<br><br>sub func1()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;TRACE(&quot;entering func1..&quot;);</font><br><br>I end up with the following message:<br><font color=red>Undefined subroutine &module_1::TRACE called at module_1.pm line 82.</font><br><br>But if module_1 is declared thus:<br><br><FONT FACE=monospace>use TRACING;<br>package TRACING;<br><br>sub func1()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;&TRACE(&quot;entering func1...&quot;);</font><br><br>I get no problems and I can call any of the subroutines in module_1 by including<br><br><FONT FACE=monospace>use module_1;</font><br><br>In my main script.<br>Surely the first definition with package module_1; should be correct.. why is TRACE not getting found? I've checked parameters etc and they seem fine!<br><br>Any help appreciated<br>Loon<br><br><br><br><br>
 
Worked it out!<br><br>My <FONT FACE=monospace>use TRACING;</font> was above my <FONT FACE=monospace>package module_1</font> declaration.<br><br>Hence I suspect that when the TRACING symbol table was loaded up it was then replaced by module_1's symbol table so the parser no longer knew the functions declared in the TRACING module.<br><br>*phew* <br>Loon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top