[oak perl] Lexical vs. Package variables
Sandy Santra
santranyc at yahoo.com
Wed Feb 9 13:10:21 PST 2005
Yes, this helps. Thanks, Jon.
At 06:14 PM 2/7/05 -0800, you wrote:
>This is absolutely the point -- you've got it. Now just generalize your
>thinking about programs to include *large* programs... programs that have
>many different subroutines to get the job done. What if you wanted a
>simple counter (e.g., $i) to count things during a loop. If you couldn't
>localize them, you'd have to use $i1 for the first subroutine, $i2 for the
>second subroutine, and so on. With even a moderate-sized system, this can
>get to be a real pain and the source of obtuse bugs. I know; a system that
>I programmed in many years ago had exactly that problem...
>
>Don't think of a *coding* script as a linear affair... think of the
>*execution* of the script as linear. If your code is executing in the main
>routine, then calls subroutine-1, which calls subroutine-2, then that's
>the "linearity" that is relevant... and which is what makes localized
>variables so valuable.
I need to learn how to change my (perceptual) thinking. This is all good.
--Sandy Santra
More information about the Oakland
mailing list