You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl@perl.apache.org by Alexander Hartmaier <Al...@t-systems.at> on 2002/06/07 11:04:13 UTC

if-elsif problem


Hi!

I just discovered a strange behavior of embperl 2.0b7....

I've got following piece of code...

if ($guitype = 'admin')
{
  $graphdir = "/home/nac/web/admin/intgraph/";
}
elsif ($guitype = 'user')
{
  $graphdir = "/home/nac/web/user/intgraph/";
}

...which doesn't work!

If I chance it...

if ($guitype = 'admin')
{
  $graphdir = "/home/nac/web/admin/intgraph/";
}
if ($guitype = 'user')
{
  $graphdir = "/home/nac/web/user/intgraph/";
}

...into 2 seperate if-statements it's working....


I thought I should ask if I'm doing something wrong but I think it's ok.

THX Alex



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Re: if-elsif problem

Posted by Vladimir Ivaschenko <ha...@hazard.maks.net>.
Fri, Jun 07, 2002 at 11:04:13AM +0200 Alexander Hartmaier wrote about if-elsif problem

> 
> 
> Hi!
> 
> I just discovered a strange behavior of embperl 2.0b7....

"=" is an assignment operator. You should "eq" to compare string values,
and "==" to compare numbers.

> 
> I've got following piece of code...
> 
> if ($guitype = 'admin')
> {
>   $graphdir = "/home/nac/web/admin/intgraph/";
> }
> elsif ($guitype = 'user')
> {
>   $graphdir = "/home/nac/web/user/intgraph/";
> }
> 
> ...which doesn't work!
> 
> If I chance it...
> 
> if ($guitype = 'admin')
> {
>   $graphdir = "/home/nac/web/admin/intgraph/";
> }
> if ($guitype = 'user')
> {
>   $graphdir = "/home/nac/web/user/intgraph/";
> }
> 
> ...into 2 seperate if-statements it's working....
> 
> 
> I thought I should ask if I'm doing something wrong but I think it's ok.
> 
> THX Alex
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
> For additional commands, e-mail: embperl-help@perl.apache.org
> 

-- 
Best Regards
Vladimir Ivaschenko
http://www.hazard.maks.net/

---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org