On Wed, Sep 07, 2005 at 05:19:55PM -0700, brucer @ gsg-lnx-bld1. cisco. com wrote: > The following program invokes beta once instead of twice. > Extremely non-intuitive. > moving the "#' down one line fixes it. > 1) seems like it shouldn't compile. > 2) $c is static and keeps its value between invocations if > one instead of "if (0)" one has "if ($b)" > This is boiled down from a real program, of course.
This is a well-known problem, which is difficult to fix without breaking backwards compatibility (some people make use of the 'feature' to create static variables). The problem boils down to: If the 'my $x' is skipped at runtime, then at scope exit the variable isn't freed, meaning that on next scope entry the variable maintains its old value. -- Standards (n). Battle insignia or tribal totems.