in reply to Different usage of "my"

In the latter case $key and $value are visible after the while loop, in the former case they are not.