I'm trying to update a Text widget as I transfer files using Net::FTP. print statements to STDOUT work as expected, and write updates to the command line as each file is transferred, but $text->insert() statements seem to be queued up, and the text box updates only once when the entire process is complete.
Hash marks are also written to STDOUT as the file is transfered, but when I redirect STDOUT to the textbox using tie:
tie *STDOUT, ref $tx_output, $tx_output; it does not update until the entire FTP process is complete.
Any ideas? I've included the subroutine which does the work, but I'm omitting the widget definitions to conserve space.
sub transfer {
my $ftp = Net::FTP->new("$ftp_server", Debug=> 0, Hash=> 1)
or die "ERROR $!\n";
$ftp->login( "$login", "$password");
foreach my $file ( @source_files ) {
my @fields = split( '/', $file );
my $dest_file = pop( @fields );
print "Transfer: $file - $dest_file\n";
$text->insert('end', "Transfer: $file - $dest_file\n");
$text->see('end');
if ( $ftp->put( "$file", "$dest_dir/$dest_file" ) ) {
$text->insert('end', " FILE TRANSFERRED\n");
} else {
$text->insert('end', " ERROR: $!\n");
$text->insert('end', " SOURCE: $file\n");
$text->insert('end', " DEST: $dest_dir/$dest_file\n");
}
}
$ftp->quit();
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.