Neither of those variables that Dump() has displayed would cause the error you see. It would be fine to use either of those 2 with the modulus operator.
Somehow, your program is seeing some other value that equates to (or is) zero. (Are warnings enabled ?)
What's happening between my $step = $hash->{'step'}; and my $mid = $lupdate % $step ; in your code ?