Come for the quick hacks, stay for the epiphanies. | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
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,
--
In reply to help with scoping (code), part 2 by deprecated
|
|