Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Real-Time TextIO

Posted on 2002-03-05
4
Medium Priority
?
134 Views
Last Modified: 2010-03-05
Hi,

I need to be able to write text into a file immediately, however, I notice that all of my writing is being done at the end of my program.

I've tried closing and re-opening my file pointer but that doesn't work.

    open (LOG_FILE,">>./AUTO_LOG/AUTO_v1_0.log");
    print LOG_FILE ("\nStuff...\n");
    close (LOG_FILE);

How do I immediately force text out to a file?

Thanks in advance,
Alex
0
Comment
Question by:Alex_Tong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 6843220
You need to turn the buffering off at the start of your script

$| = 1;

0
 
LVL 16

Expert Comment

by:maneshr
ID: 6843450
Alex_Tong,

Welcome back!!

You have the following question open for a long time now. Please take some time to close this question.

EE userid Alex_Tong
Total questions asked 29 (100%)
Open questions 1
       
Topic Area              URL              Date              
C Programming   http://www.experts-exchange.com/jsp/qShow.jsp?ta=cprog&qid=20079044   02/16/01  

Your help in closing this question will be highly appreciated.

Thanks

maneshr
(NOT a moderator at EE)
0
 
LVL 1

Accepted Solution

by:
japhyRPI earned 200 total points
ID: 6843548
teraplane was close, but you need to turn off buffering for the filehandle(s) you need, via the select() function:

  open LOGFILE, ">> logfile" or
    die "can't append to logfile: $!";
  {
    my $oldfh = select LOGFILE;
    $| = 1;
    select $oldfh;
  }
  # ...
0
 
LVL 16

Expert Comment

by:maneshr
ID: 6845649
Alex_Tong,

Thank you for taking the time to close the open question.

Your help is highly appreciated.

maneshr
(NOT a moderator at EE)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

660 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question