in reply to Re: How to escape from sub to beginning of script?
in thread How to escape from sub to beginning of script?

This jails me in the options menu - whatever option user will select it prints the menu until user select 0 and it quit.
  • Comment on Re^2: How to escape from sub to beginning of script?

Replies are listed 'Best First'.
Re^3: How to escape from sub to beginning of script?
by choroba (Cardinal) on Mar 29, 2012 at 12:52 UTC
    OK, so add exit to other options :-)

    Or, use a different variable, e.g. $restart, and set it to 1 only if you want to restart the loop. The loop then becomes

    $restart = 1; while ($restart) { $restart = 0; .... }
    Or whatever similar.
Re^3: How to escape from sub to beginning of script?
by Mery84 (Novice) on Mar 29, 2012 at 12:53 UTC
    Ok got it. I`ve wrong inserted the until statement.
    Thanks for your help :).
      The correct way for others who may reach this thread from google :)
      until ($question1 eq "0") { &pytaj(); if ($question1 eq '') { print "Nie wybrales zadnej opcji \n"; print "Zamykam.... \n"; sleep(5); exit(); } elsif ($question1 eq "1") { &backup(); } elsif ($question1 eq "2") { &restore(); } elsif ($question1 eq "3") { &testowanie(); } elsif ($question1 eq "4") { &full(); } elsif ($question1 eq "5") { &shared(); } elsif ($question1 eq "6") { &archive(); } elsif ($question1 eq "0") { print "Ok wiec koniec pracy. Zamykam.... \n"; sleep(5); exit(); } }