#This is the main script
#!/usr/bin/perl
use strict;
use Tk;
use Cwd;
use warnings;
use product_search;
use missing_articles;
require Tk::DialogBox;
require Tk::LabEntry;
use Spreadsheet::WriteExcel;
$tx = $mainFrame->Scrolled(qw/Text
-font normal
-width 73
-height 15
-wrap word
-scrollbars e/
)->pack;
tie *STDOUT, 'Tk::Text', $tx;
#click Tk button and it calls a module passing the argument and the us
+er input
product_search::search($si1, $fullSearch);
The module runs through a list of products and finds matches, formats them for output, such as stripping product numbers if it has any in the product title, etc. As this process compares products, the print command is sending feedback to the user that should output in the scrolled text box above in the main perl script. At the moment, none of the stuff prints to the scrolled text box until the module has completed, instead of giving the user feedback as it runs the module
Code for module
#!/cygdrive/c/Perl/bin/perl
package product_search;
use strict;
use strip_product_numbers;
sub search {
# Grab parameters that are passed to this module
my ($si1, $fullSearch) = @_;
# As it finds a product that matches, it processes it (strips
+product number from title, etc) then should print it
print "$product\n\n";
} 1;
So instead of printing all the products once the module finishes up, I want to print them as it processes. I am also printing status of the module and completion, so in case there is an error the user can give me a better idea where it is erring out, at this time, if the module fails, nothing is printed at all in the scrolled text box which won't help the user to tell me the problem and help me most closely identify it.
Thanks for all the help |