I understand what you are trying to do...identify a bug, modify the code, and continue debugging with the modified code. That would be very nice.
I think I can point out that you could at least change it for this instance and continue debugging. For example, usin g your code:
At this point you could set the value of $x before the unless expression is evaluated:
Of course, you would have to remember to make the same modification in code...
As an interesting alternative, you could redefine the function on the fly... This wouldn't work in your example because it dies on a fail case. However after a first run through the function, cut the function from an editor and paste it into the debugger with the change you desire. Subsequent runs restarts through the debugger would have the modified version of the function.
Then I run this in the debugger... After the first execution of foo Cut and paste the modified subroutine in to the debugger and execute it. This redefines the foo function.
I'm not sure if this is practicle, but it is interesting... :)
Hazah! I'm Employed!