I think you want
$perch = 100.0*($close-$first)/$first;
or (equivalently)
$perch = 100.0*($close/$first-1);
Note that you have to be sure that $first is > 0. After all, if $first is zero, and $close is anything bigger, then the percentage change is infinite!
There are two reverse operations; one when $close is needed form $first and $perch, and one when $first is needed from $close and $perch. A trivial bit of algebra gives:
$first = $close/($perch/100.0+1);
$close = ($perch/100.0+1)*$first;