in reply to Re: Initialization of "local static" (style question)
in thread Initialization of "local static" (style question)

use my in a block enclosing both

I had thought that my function would not be visible outside the block then, but of course, functions are always global. Nice idea!

I will remember it for use in a later project, though, because in my current one, the automatic documentation system requires that the documentation of a function appears immediately before the line starting with 'sub', which means that I would have to move the declaration of $myval in front of the function docs.

-- 
Ronald Fischer <ynnor@mm.st>
  • Comment on Re^2: Initialization of "local static" (style question)

Replies are listed 'Best First'.
Re^3: Initialization of "local static" (style question)
by massa (Hermit) on Feb 03, 2009 at 12:13 UTC
    One option would be to use closures.
    ## DOC: returns a function that does that and that. sub ff { my $myval=myfunc(); ... sub { g(++$myval) } } ... my $f = ff; ... my $x = $f->();
    []s, HTH, Massa (κς,πμ,πλ)