I need to redirect STDOUT output, after a perl format has been applied, to populate a Scrolled text field. I'm filtering values from a CSV file compared to user input, and displaying them in nice columns with headers and such...I did try using a custom swrite function (using $^A to accumulate the lines), as well as using a buffer to populate an array, but none seemed to work quite right...but that's probably my fault ;) I'm trying to avoid using a temp file, then reading it into the text field, but I'm beginning to feel it's the only way! (But there's more than one way I bet) Any help, ideas, or resources I need to check are greatly appreciated!
#the scrolled list box....
$result = $mw->Scrolled("Text",-scrollbars=>'e')->pack();
sub search{
my $selected = shift;
$result->delete('end','1.0');
#open CSV file for searching
open(FH,"$file") or die "Error: Can't open csv file.\n";
while(<FH>)
{
$current = ((split "\t",$_)[0]);
$customer = ((split "\t",$_)[1]);
$description = ((split "\t",$_)[2]);
$fee = ((split "\t",$_)[3]);
$expense = ((split "\t",$_)[4]);
if($current=~/$selected/)
{
#counter
&increment;
#Here's where I need to redirect output to
#the Scrolled field instead of console
write;
#$result->insert('end', $_);
}
}
close(FH);
$result->insert('end',"-------------\n");
$result->insert('end',"$rc record(s) found.\n");
}
###formatting instructions###
format STDOUT_TOP =
Search Program
CURRENT DESCRIPTION CUSTOMER FEE EXPENSE
_____________________________________________________________________________________________________________________
.
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<@>>>>>>>>>>>>>>>>>>@>>>>>>>>>>>
$current $description $customer $fee $expense
.
###end formatting instructions###
#the scrolled list box....
$result = $mw->Scrolled("Text",-scrollbars=>'e')->pack();
sub search{
my $selected = shift;
$result->delete('end','1.0');
#open CSV file for searching
open(FH,"$file") or die "Error: Can't open csv file.\n";
while(<FH>)
{
$current = ((split "\t",$_)[0]);
$customer = ((split "\t",$_)[1]);
$description = ((split "\t",$_)[2]);
$fee = ((split "\t",$_)[3]);
$expense = ((split "\t",$_)[4]);
if($current=~/$selected/)
{
#counter
&increment;
#Here's where I need to redirect output to
#the Scrolled field instead of console
write;
#$result->insert('end', $_);
}
}
close(FH);
$result->insert('end',"-------------\n");
$result->insert('end',"$rc record(s) found.\n");
}
###formatting instructions###
format STDOUT_TOP =
Search Program
CURRENT DESCRIPTION CUSTOMER FEE EXPENSE
_____________________________________________________________________________________________________________________
.
format STDOUT =
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<<<<<<<<<<@>>>>>>>>>>>>>>>>>>@>>>>>>>>>>>
$current $description $customer $fee $expense
.
###end formatting instructions###