File Buffering

2004-10-01 Thread Dirk Bremer \(NISC\)
I wrote and use a module that provides a standardized logging mechanism to
STDOUT and to a defined log file. I have several Perl programs that run all
of the time and use this module. The log file is opened at the program start
and closed at the program end. There is nothing particularly fancy or
complicated with the way that the module opens, writes, or closes the file.
The file is created as a normal text file and regular print functions are
used to write to it.

While a given program is running an writing to the log file, the log file
can be opened in Notepad and the contents examined. Herein lies the issue,
the program seems to lag behind in the writes to the log file based upon the
known program activity, i.e. there are entries I expect to see in the log
file that are not there, but after a period of time, the log file will catch
up and I will see the results. All entries to the log file are timestamped
so that I know when events occurred.

I thing that there is some kind of file buffering going on here, i.e. the
log entries are in a file buffer that has not been flushed to the file. The
file is using a specific file handle, i.e. it is not being written to STDOUT
or STDERR.

I have never really understood the buffering mechanism as employed by Perl
and could use some knowledge in this area. Specifically, how can I force
every write to the log file to be unbuffered? Is the problem with buffering
or is there something else I should look at?

Note: Using Perl 5.6.1 on Win2K.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: File Buffering

2004-10-01 Thread Peter Guzis
select YOURFILEHANDLE;
$| = 1;

# enjoy unbuffered file goodness

-Original Message-
From: Dirk Bremer (NISC) [mailto:[EMAIL PROTECTED]
Sent: Friday, October 01, 2004 1:28 PM
To: [EMAIL PROTECTED]
Subject: File Buffering


I wrote and use a module that provides a standardized logging mechanism to
STDOUT and to a defined log file. I have several Perl programs that run all
of the time and use this module. The log file is opened at the program start
and closed at the program end. There is nothing particularly fancy or
complicated with the way that the module opens, writes, or closes the file.
The file is created as a normal text file and regular print functions are
used to write to it.

While a given program is running an writing to the log file, the log file
can be opened in Notepad and the contents examined. Herein lies the issue,
the program seems to lag behind in the writes to the log file based upon the
known program activity, i.e. there are entries I expect to see in the log
file that are not there, but after a period of time, the log file will catch
up and I will see the results. All entries to the log file are timestamped
so that I know when events occurred.

I thing that there is some kind of file buffering going on here, i.e. the
log entries are in a file buffer that has not been flushed to the file. The
file is using a specific file handle, i.e. it is not being written to STDOUT
or STDERR.

I have never really understood the buffering mechanism as employed by Perl
and could use some knowledge in this area. Specifically, how can I force
every write to the log file to be unbuffered? Is the problem with buffering
or is there something else I should look at?

Note: Using Perl 5.6.1 on Win2K.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: File Buffering

2004-10-01 Thread Dirk Bremer \(NISC\)
Peter and Michael,

Your advice seems to have done the trick. Have a great weekend.

Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
USA Central Time Zone
636-922-9158 ext. 8652 fax 636-447-4471

[EMAIL PROTECTED]
www.nisc.cc
- Original Message - 
From: Peter Guzis [EMAIL PROTECTED]
To: Dirk Bremer (NISC) [EMAIL PROTECTED];
[EMAIL PROTECTED]
Sent: Friday, October 01, 2004 15:44
Subject: RE: File Buffering


 select YOURFILEHANDLE;
 $| = 1;

 # enjoy unbuffered file goodness

 -Original Message-
 From: Dirk Bremer (NISC) [mailto:[EMAIL PROTECTED]
 Sent: Friday, October 01, 2004 1:28 PM
 To: [EMAIL PROTECTED]
 Subject: File Buffering


 I wrote and use a module that provides a standardized logging mechanism to
 STDOUT and to a defined log file. I have several Perl programs that run
all
 of the time and use this module. The log file is opened at the program
start
 and closed at the program end. There is nothing particularly fancy or
 complicated with the way that the module opens, writes, or closes the
file.
 The file is created as a normal text file and regular print functions are
 used to write to it.

 While a given program is running an writing to the log file, the log file
 can be opened in Notepad and the contents examined. Herein lies the issue,
 the program seems to lag behind in the writes to the log file based upon
the
 known program activity, i.e. there are entries I expect to see in the log
 file that are not there, but after a period of time, the log file will
catch
 up and I will see the results. All entries to the log file are timestamped
 so that I know when events occurred.

 I thing that there is some kind of file buffering going on here, i.e. the
 log entries are in a file buffer that has not been flushed to the file.
The
 file is using a specific file handle, i.e. it is not being written to
STDOUT
 or STDERR.

 I have never really understood the buffering mechanism as employed by Perl
 and could use some knowledge in this area. Specifically, how can I force
 every write to the log file to be unbuffered? Is the problem with
buffering
 or is there something else I should look at?

 Note: Using Perl 5.6.1 on Win2K.

 Dirk Bremer - Systems Programmer II - ESS/AMS  - NISC St. Peters
 USA Central Time Zone
 636-922-9158 ext. 8652 fax 636-447-4471

 [EMAIL PROTECTED]
 www.nisc.cc

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

 ___
 Perl-Win32-Users mailing list
 [EMAIL PROTECTED]
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs