in reply to having trouble with count

The code does what you tell it to do:
$count = @z;
Also, instead of
@value = (@value , $value);
you'd normally use
push @value,$value;
(and it is usually not a good idea to have two variables with the same name)