On Sunday, July 7, 2002, at 05:47  AM, David T-G wrote:

> Hi, all --
>
> It must still be early, because I just don't get this.
>
> Given the snippet
>
>   sub setpath(my $shelltype)
>   {
>     my ($setenv,$equals) ;
>   #  $_[0] =~ /tcsh/ && $setenv = "setenv" ;
>   #  $_[0] =~ /tcsh/ && { $setenv = "setenv" ; } ;
>   #  $_[0] =~ /tcsh/ && { $setenv = 'setenv' ; } ;
>   #  if $_[0] =~ /tcsh/
>   #    {
>   #      $setenv = "setenv" ;
>   #      $equals = " " ;
>   #    }
>     $setenv = "setenv" if $_[0] =~ /tcsh/ ;
>     $equals = " " if $_[0] =~ /tcsh/ ;
>     $setenv = "" if $_[0] =~ /tcsh/ ;
>     $equals = "=" if $_[0] =~ /bash/ ;
>
> can you please tell me why the various commented formats don't work?  I'm
> going to need to set multiple things, so the last commented version is
> best, but even more I just plain don't like "action if test" format :-)
>

you need to use 'and' instead of '&&'  because of precedence.
using 'w' option would have showed problem:
Can't modify logical and (&&) in scalar assignment at ./tst line 5, near 
""yes\n" ;"  (in my own test)

also, the 'if' statement needs parens around the condition.

pob


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to