[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Subroutines



>> -----
>> if ($UserPassword eq $Data[1]) {
>>   print "Password accepted.\n";
>>   MainMenu     ###  <---- problem here ----
>>   } else {
>>   print "Password invalid.\n";
>>   die "Invalid password - open program again for another try.\n";
>>   }
>> 
>> sub MainMenu {
>>   print "A.) Enter another deduction,\n";
>>   print "B.) Review past 5 deductions,\n";
>>   print "C.) Review past 2 deposits,\n";
>>   ...  [not continued]
>>   }
>> -----
>
> Change the marked line to
>
>   &MainMenu
>
> You may leave out the '&' if you define your subroutine _before_
> calling it in your code; in your case the '&' is required.

you could also change it to:

   MainMenu();

which i find to be more readable.

--
Darin S. Morley
dmorley@std.saic.com