Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Writing to a file

Writing to a file

Writing to a file

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.

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).

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.


RE: Writing to a file

maybe????? you could set your print buffer to autoflush........like

$¦ = 1;

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.

'hope this helps...

keep the rudder amid ship and beware the odd typo

RE: Writing to a file

Thanks! I'll try that, maybe someone can also help me out
with the error message I am getting...

Module 1 uses the TRACING module
My program uses Module 1.....

However, if I declare module 1 thus:

package module_1;

sub func1()
    TRACE("entering func1..");

I end up with the following message:
Undefined subroutine &module_1::TRACE called at module_1.pm line 82.

But if module_1 is declared thus:

package TRACING;

sub func1()
    &TRACE("entering func1...");

I get no problems and I can call any of the subroutines in module_1 by including

use module_1;

In my main script.
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!

Any help appreciated

RE: Writing to a file

Worked it out!

My use TRACING; was above my package module_1 declaration.

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.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close