MainLoop; ##**********************************************8 #when i click the button i window appears then close it #program exits sub openEksoda_button { do "eksoda.pl"; } sub openEsoda_button { #************************** #Same case here do "esoda.pl"; } sub Eksoda_Statistika_button { my @totalEksoda = (); my $eksodasum = 0; my $clearedeksodaValue=0; chdir "/home/props/delice/eksoda" or die "didn't make to eksoda folder\n"; foreach my $file (glob '*.txt') { open IN, $file; while () { if ($_ =~ m/(Eksoda.*Total:)(.*\d)/) { $clearedeksodaValue =$2; push(@totalEksoda,$clearedeksodaValue); } #if } #end while } #end outer foreach foreach (@totalEksoda){ $eksodasum+= $_; } #end inner foreach chomp $eksodasum; my $displayeksodasum ='Ta eksoda einai:' ." $eksodasum"; #************************************************ #this works nicely since gets me back to previous interface without exiting the program my $DialogRef = $mw->Dialog( -text =>$displayeksodasum ); $esodaSTmb = $DialogRef->Show; } #end sub sub Esoda_Statistika_button { my @totalEsoda = (); my $esodasum = 0; my $clearedesodaValue=0; chdir "/home/props/delice/esoda" or die "didn't make to esoda folder\n"; foreach my $file (glob '*.txt') { open IN, $file; while () { if ($_ =~ m/(Esoda.*Total:)(.*\d)/) { $clearedesodaValue =$2; push(@totalEsoda,$clearedesodaValue); } #if } #end while } #end outer foreach foreach (@totalEsoda){ $esodasum+= $_; } #end inner foreach chomp $esodasum; my $displaysum ='Ta esoda einai:' ." $esodasum"; #********************************************************* #here the same as expected my $DialogRef = $mw->Dialog( -text =>$displaysum ); $esodaSTmb = $DialogRef->Show; } #end sub