in reply to Re: Re: Perl Turning a Blind Eye
in thread Perl Turning a Blind Eye

Is %funcN_data something that needs to be declared and kept as information in the main block? Is another function besides funcN going to need that information? If so, it's global data, you should declare it right away. Otherwise, it can be made lexical to funcN by putting the  my (%funcN_Data) = (stuff); inside the sub {}'s. If the data in that hash is persistent, this looks like an excellent case for using package and bless-- and now you're into OO Perl, which will probably feel familiar to someone coming from a C++ background.

Replies are listed 'Best First'.
static variables (Re: Perl Turning a Blind Eye)
by tye (Sage) on Jan 30, 2001 at 03:42 UTC

    Perl lacks a great way to declare static variables.

    sub routine { my $static if 0; $static= 'value' if ! defined $static; # ... }
    is the closest you can come and that (once you think about it enough) makes my solution look downright tasty. (:

            - tye (but my friends call me "Tye")