in reply to problem in for loop

I think you have an error here:

if ($a=$b=$c=$d=$x=$w=$y=$z = 0)

That will never be true - it is just assigning 0 to all those variables. I think you meant to check that they are all zero. To do that, you would want this code:

if (0 == grep $_ != 0, $a,$b,$c,$d,$x, $w,$y,$z) { say "all zero"; }