Page 1 of 1

perl to php code change?

Posted: Sat Jan 22, 2005 1:09 am
by deras
i am moving a script from perl to php and i the following array does not work in the new php version. what do i need to change to get it to work?

Code: Select all

@x=($m1,$m2,$m3);
$n=1;
foreach $v(@x){
$var="md".$n;
if($v > 90 ){$$var ="||||||||||||||||||||||";}
elsif($v >80 ){$$var ="||||||||||||||||||||";}
elsif($v > 70 ){$$var ="||||||||||||||||||";}
elsif($v > 60 ){$$var ="||||||||||||||||";}
elsif($v > 50 ){$$var ="||||||||||||||";}
elsif($v > 40 ){$$var ="||||||||||||";}
elsif($v > 30 ){$$var ="||||||||||";}
elsif($v > 20 ){$$var ="||||||";}
elsif($v > 10 ){$$var ="||||";}
elsif($v > 0 ){$$var ="||";}
$n++;
  }

Posted: Sat Jan 22, 2005 1:16 am
by feyd

Code: Select all

$x = array($m1, $m2, $m3);
$n = 1;
foreach($x as $v)
{
  $var = 'md' . $n;
  if($v > 90 ){$$var ="||||||||||||||||||||||";}
elsif($v >80 ){$$var ="||||||||||||||||||||";}
elsif($v > 70 ){$$var ="||||||||||||||||||";}
elsif($v > 60 ){$$var ="||||||||||||||||";}
elsif($v > 50 ){$$var ="||||||||||||||";}
elsif($v > 40 ){$$var ="||||||||||||";}
elsif($v > 30 ){$$var ="||||||||||";}
elsif($v > 20 ){$$var ="||||||";}
elsif($v > 10 ){$$var ="||||";}
elsif($v > 0 ){$$var ="||";}
$n++;
  }
I think.. it's been a while since I worked in perl..

Posted: Sat Jan 22, 2005 1:48 am
by AGISB
$$var ?

Posted: Sat Jan 22, 2005 1:50 am
by feyd
AGISB wrote:$$var ?
variable variables: http://www.php.net/manual/en/language.v ... riable.php

Posted: Sat Jan 22, 2005 1:52 am
by AGISB
But in Perl that is a Perl Process ID Variable so I guess there is your possible error

Posted: Sat Jan 22, 2005 1:53 am
by feyd
true.. but he did say he's moving stuff over from perl to php.. so I take the code as half perl, half php. :)

Posted: Sat Jan 22, 2005 1:55 am
by AGISB
So I guess we need more input of what this code is supposed to do and what is does at the moment ;)

Posted: Sat Jan 22, 2005 2:22 am
by deras
what i posted was 100% perl code