in reply to Problem with a replacement

When you write

$init_name = "init_$ncat"

$init_name is assigned a value. Now no matter how many times you change the value of $ncat you don't change the value of $init_name

Try printing value of $init_name instead of $ncat

--
Regards
- Samar