in reply to How not to write subroutines

I have no idea what you were thinking.

All you are doing by putting this code in a BEGIN block is making sure it runs before anything else, but I do not see anything in it that necessarily has to be in a BEGIN block. You can have it at the top of the code and it would run the same.

Your debug sub will print the same original values for $a, $b and $c. If you want to print current values, you should be passing the values to the debug sub (and change it to accept the passed values, it is best not to use globals either).

Did this accomplish what you wanted in your script?

-imran

Replies are listed 'Best First'.
Re^2: How not to write subroutines
by gustavderdrache (Acolyte) on Jan 15, 2006 at 15:24 UTC

    Oh, no, this is a stripped-down version. The original code had several subroutines that needed initialization with lots of variables. This is just the interesting (that is, weird) part.

    "If you go on with this nuclear arms race, all you are going to do is make the rubble bounce" -- Winston Churchill