in reply to How to escape from sub to beginning of script?

Just enclose the call to &pytaj into
until ($question1 eq '0') { pytaj(); }
No exit would be then needed if the user specifies 0.

Replies are listed 'Best First'.
Re^2: How to escape from sub to beginning of script?
by Mery84 (Novice) on Mar 29, 2012 at 12:43 UTC
    This jails me in the options menu - whatever option user will select it prints the menu until user select 0 and it quit.
      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.
      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(); } }