props has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks I have a Tk interface with 4 buttons one next to another. 2 of them execute subroutines of the form : do "esoda.pl"; and do "eksoda.pl"; . Those 2 files are stored in the current folder as expected. Now the other 2 buttons are using the Tk::Dialog module and they subroutines when are triggered display some information to the user. my $DialogRef = $mw->Dialog( -text =>$displayeksodasum ); $esodaSTmb = $DialogRef->Show; With the TK:Dialog module you can close the windows and return to the previous interface ( the initial with the 4 buttons remember?). But when i click the other 2 windows with code such as do "esoda.pl" or "eksoda.pl" when i close that window i exit the program without returning to the initial 4 button interface. I need some guidance in making the 2 last buttons to utilise Toplevel functionalities so whenever i leave that window to return to the previous interface. Now you may ask: why just do not copy what you have done for the first 2 buttons to the last 2, well the problem is that since are external files envoked i do not really fell confident plus i have serious thoughts of merging all three files eksoda.pl , esoda.pl and main.pl into one but this would be a catastrophe here is the code
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 folde +r\n"; foreach my $file (glob '*.txt') { open IN, $file; while (<IN>) { 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 ex +iting 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 (<IN>) { 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

Replies are listed 'Best First'.
Re: Tk-Toplevel related
by jdporter (Paladin) on Oct 10, 2007 at 20:56 UTC

    Are you sure those two external .pl files were meant to be executed via do? Unless they were, you should probably be executing them with system instead. That could certainly cause the problem you're seeing.

    A word spoken in Mind will reach its own level, in the objective world, by its own weight
Re: Tk-Toplevel related
by shmem (Chancellor) on Oct 10, 2007 at 21:09 UTC
    You're not precisely a newcomer to PerlMonks, but you have few posts, and maybe you come here only if you have a pressing problem, and don't wander through the monastery as others do. That's all fine and well.

    I have written this preamble like "thinking aloud", and musing how harsh I can be to you. Well, I won't, no reason for that. But the formatting / indenting of your code is poor, and you don't include in your post all that is necessary for me (maybe others have more divining strength) to work out where the real problem might be.

    What's in the files esoda.pl and eksoda.pl?

    From your previous postings and the answers to these, it seems like you have not been directed to two essential nodes. Please read these nodes:

    Please skim at least the PerlMonks FAQ and the Tutorials Section. You will benefit greatly doing so, since you will (as I hope) get aware of the fact that the better you lay out the maps you can't read, the better we will be able to show you the road.

    --shmem

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Many thanks shmen . I know my questions are awful and need some improvement definitely. I read the sources you posted me and i will rephrase them better in the future :)
Re: Tk-Toplevel related
by zentara (Cardinal) on Oct 11, 2007 at 13:03 UTC
    My first thought is the external files may have an "exit" in them. You don't need Tk to demonstrate this. Comment out the do and system lines in caller, and see the difference. Basically "do" runs the external script as if it where part of the caller, and if it hits an exit.....bye bye.
    #caller #!/usr/bin/perl $|++; print "start\n"; do "test"; #system ("./test"); print "done\n";
    #test #!/usr/bin/perl print "test\n"; exit;

    I'm not really a human, but I play one on earth. Cogito ergo sum a bum