in reply to Re: Concatenating scripts intelligently
in thread Concatenating scripts intelligently

Both solutions posted so far rely on having onInit be the one declaration section,

Not at all. Concatenate them! ( Oh I see, they're suppose to be called at different times. That means while the compilation of onRestore's snippet has to be done at the same time as the compilation preRestore's snippet's, their execution occur at different times. Truly my solution does not do that. )

Oh, and I like the idea of sandboxing everything into a package -- but I'm already doing that

Despite the name, my code isn't sandboxed. It can freely modify other packages. You'd probably have to use Safe to truly sandbox some code.

Replies are listed 'Best First'.
Re^3: Concatenating scripts intelligently
by sfink (Deacon) on May 09, 2006 at 23:11 UTC
    Sorry, I was using "sandboxing" loosely. It's still useful, especially since when I delete one of these script tag nodes, I can use Symbol.pm to delete its package and get rid of most of what it did in the (global) perl interpreter. If the script puts anything into another package, then it will survive indefinitely -- but that is usually more of a feature than a drawback, since it can be convenient to write a script that, say, rewrites the menu system permanently when you run it. I'd rather give script writers loaded bazookas and maps showing where their feet are, than try to enforce limitations externally.

    Having a unique package is good for other things too, but I don't suppose it's relevant to this thread.