Forum Webscript.Ru

Программирование => Perl => Тема начата: alexxmfk от 03 Ноября 2002, 20:44:48

Название: Мааааалегький вопрос
Отправлено: alexxmfk от 03 Ноября 2002, 20:44:48
Как мне правильно оформать вот такую лабуду:

if ($index eq \'index\'){$cat_url=$index_url;}
else {$cat_url=$public_url."/$in{\'cat_id\'}";}
else if ($index eq \'forum\'){$cat_url=/forum/;}
else if ($index eq \'main\'){$cat_url=/index.php;}
else if ($index eq \'links\'){$cat_url=/links/;}
else if ($index eq \'chat\'){$cat_url=/chat/;}
else if ($index eq \'files\'){$cat_url=/files/;}
else if ($index eq \'about\'){$cat_url=/about/;}
else if ($index eq \'adv\'){$cat_url=/adv/;}
else if ($index eq \'subscribe\'){$cat_url=/subscribe/;}
else if ($index eq \'contact\'){$cat_url=/contact/;}
else if ($index eq \'gallery\'){$cat_url=/gallery/;}
else if ($index eq \'hosting\'){$cat_url=/hosting/;}

а то этот вариант не работает.
Название: Мааааалегький вопрос
Отправлено: alexxmfk от 03 Ноября 2002, 20:50:26
Поторопился я с вопросом...
надо было так:
if ($index eq \'index\'){$cat_url=$index_url;}
else {$cat_url=$public_url."/$in{\'cat_id\'}";}
if ($index eq \'forum\'){$cat_url=\'/forum/\';}
if ($index eq \'main\'){$cat_url=\'/index.php\';}
if ($index eq \'links\'){$cat_url=\'/links/\';}
if ($index eq \'chat\'){$cat_url=\'/chat/\';}
if ($index eq \'files\'){$cat_url=\'/files/\';}
if ($index eq \'about\'){$cat_url=\'/about/\';}
if ($index eq \'adv\'){$cat_url=\'/adv/\';}
if ($index eq \'subscribe\'){$cat_url=\'/subscribe/\';}
if ($index eq \'contact\'){$cat_url=\'/contact/\';}
if ($index eq \'gallery\'){$cat_url=\'/gallery/\';}
if ($index eq \'hosting\'){$cat_url=\'/hosting/\';}
Название: Мааааалегький вопрос
Отправлено: Serchey от 03 Ноября 2002, 21:17:33
use if ($a<$b) {...;} elsif ($a>$b) {...;} elsif.....}else{...;}
Название: Мааааалегький вопрос
Отправлено: alexxmfk от 03 Ноября 2002, 23:09:56
tnx