![]() |
|
The stupid question is the question not asked | |
PerlMonks |
help with scoping (code), part 2by deprecated (Priest) |
on Nov 04, 2001 at 02:16 UTC ( #123097=perlquestion: print w/replies, xml ) | Need Help?? |
deprecated has asked for the wisdom of the Perl Monks concerning the following question:
As I outlined in 123089, I have some questions about scoping.
In college, we learned about 'static' variables. Alas, that was long enough ago that I dont recall whether it was pascal or C in which they were available. At any rate, the gist of it was that I could expect something like this: In the above, because foo received a value for bar, and bar was static, i could continue to use it after the sub had exited. The reason for this is I would like a persistance of objects. Lets say that I do this: The problem is $object might take forever to create, or, even worse, it might have a socket connection in it (as is the case with MP3::Napster), and continually recreating it is not good. What I would like to do is this: I realize that some trickery would have to be employed, like using storable or dumper to actually store the object rather than a direct reference to it. This would allow me to call less_slow from within @children without losing connections, re-creating the object, et cetera.
thanks,
--
Back to
Seekers of Perl Wisdom
|
|