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

Re: [MacPerl] Novice question regards subroutines



>>it does the same
>>function time and time and time again.  I have to Apple-. to escape and
>>then close it.  Below is the script.
>
>>  if ($MainMenu = "1") {
>>    &CheckMenu;
>>  }
>
>etc., etc.

I tried using == and the perl script aborted compilation due to errors...

>The equal sign "=" is an assignment operator, not a comparison operator.
>When it gets to the first "if," $MainMenu is set to "1" successfully, so the
>expression returns true. You need to use "==" for numeric comparisons and
>"eq" for string comparisons. So what you want is:
>
>  if ($MainMenu == 1) {
>    &CheckMenu;
>  }
>
>or you could use:
>
>  if ($MainMenu eq "1") {
>    &CheckMenu;
>  }

I have always had the train of thought that if you're comparing letters
(ABC) to (ABC) letters, you need to use the eq; if you're comparing numbers
(123) to numbers (123) you always use = or ==.  Can somebody clarify that?
I gathered that from the learning perl and programming perl books.

Thanks.

>Of course, all the comparisons need to be fixed, not just the first.
>
>I didn't try to follow the whole script for any other errors - just fix
>these and see what happens.
>
>Steve Swantz
>maxeper@concentric.net

Tim

--------------------------------------------------------------------------------
"If the opposite of 'pro' is 'con' ...
    does that mean the opposite of 'progress' is 'congress'??"  -- Unknown
--------------------------------------------------------------------------------



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch