For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > February 2008 > perl buffering & Tk









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author perl buffering & Tk
MK

2008-02-18, 8:11 am

Does any one know if there are buffering issues specific to Tk? Eg., a
filehandle other than STDOUT to which inserts, etc. are sent?

I recently learned about the time-delay factor with perl buffers and have
been unable to correct them following the advice of the FAQ(s) and
mailing lists. Here's the example:

use IO::Handle;

sub tmptest {
STDOUT->autoflush(1); # $FLT is a text area
$MW->title("processing...");
my $data = $FLT->get('1.0','end'); @LData = split(/\n/,$data);
$FLT->delete('1.0','end');
foreach (@LData) {
#chomp $_;
my $name = basename($_);
$FLT->Insert("$name\n"); STDOUT->flush();
sleep 1; # simulate file transfer time
}
$MW->title("...test done");
}

The routine runs fine, except that even "processing..." does not appear
until everything is done (at least i presume it does, because it is
actually immediately superseded by "...test done"). The real routine
does large file transfers and i would like to be able to monitor them one
at a time. Instead, if there are ten files, i wait ten seconds and then
the results of all ten appear with ("...test done").

All the appropriate buffering commands i could find are used, but i have
never seen them work. Anyone with experience and advice here would be
much appreciated.
Marc Dashevsky

2008-02-18, 7:13 pm

In article < dpmdnXJhB55bDSTanZ2dnUVZ_s6mnZ2d@pghconn
ect.com>, halfcountplus@intergate.com
says...
> Does any one know if there are buffering issues specific to Tk? Eg., a
> filehandle other than STDOUT to which inserts, etc. are sent?


$MW->update; # whenever you want the screen updated

> I recently learned about the time-delay factor with perl buffers and have
> been unable to correct them following the advice of the FAQ(s) and
> mailing lists. Here's the example:
>
> use IO::Handle;
>
> sub tmptest {
> STDOUT->autoflush(1); # $FLT is a text area
> $MW->title("processing...");
> my $data = $FLT->get('1.0','end'); @LData = split(/\n/,$data);
> $FLT->delete('1.0','end');
> foreach (@LData) {
> #chomp $_;
> my $name = basename($_);
> $FLT->Insert("$name\n"); STDOUT->flush();
> sleep 1; # simulate file transfer time
> }
> $MW->title("...test done");
> }
>
> The routine runs fine, except that even "processing..." does not appear
> until everything is done (at least i presume it does, because it is
> actually immediately superseded by "...test done"). The real routine
> does large file transfers and i would like to be able to monitor them one
> at a time. Instead, if there are ten files, i wait ten seconds and then
> the results of all ten appear with ("...test done").
>
> All the appropriate buffering commands i could find are used, but i have
> never seen them work. Anyone with experience and advice here would be
> much appreciated.
>


--
Go to http://MarcDashevsky.com to send me e-mail.
MK

2008-02-18, 7:13 pm

Note that if i include a normal print statement, the print comes out
properly, ie. one per second (even without IO::Handle, flush, etc.)

> foreach (@LData) {
> my $name = basename($_);
> $FLT->Insert("$name\n"); STDOUT->flush();

print "$_\n"; #the new print statement
> sleep 1; #simulate file transfer time
> }
> $MW->title("...test done");
> }

MK

2008-02-18, 7:13 pm

On Mon, 18 Feb 2008 10:03:48 -0500, Marc Dashevsky wrote:

> In article < dpmdnXJhB55bDSTanZ2dnUVZ_s6mnZ2d@pghconn
ect.com>,
> halfcountplus@intergate.com says...
>
> $MW->update; # whenever you want the screen updated


Yay! Wow! Thanks!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com