home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!nntp1.radiomail.net!fernwood!autodesk!dansmith
- From: dansmith@Autodesk.COM (Daniel Smith)
- Newsgroups: comp.lang.perl
- Subject: switching off symtabs via %_foo assignments?
- Message-ID: <18160@autodesk.COM>
- Date: 17 Dec 92 19:31:33 GMT
- Organization: Autodesk Inc., Sausalito CA, USA
- Lines: 52
-
-
- Let's say you have some interactive Perl script, and you
- want to have more than one instantiation [1] of it, but that you want
- to do that within the same process...
-
- [1] as in, you want to push a menu and use the same routines and all,
- but have a unique set of variables for that "push"
-
- I've thought of going through something I'm writing and
- putting "$instance_name'some_var" in place of "$some_var". I don't like
- that idea :-)
-
- I'm wondering if it's "safe" to swap "%_some_package" around. Let's
- say I fire off my script, and I'm in the "main" package. So far so good...
- Now before getting too far into the code, I say something like:
-
- eval "package instance_1";
- %_instance_1 = %_main;
-
- So now I'm in a "instance_1" context, right? I think it means
- that I just picked up the entire symtab from main (bear with me, I'm still
- trying to figure this stuff out). I think I get a benefit of not having
- to change any code.
-
- If I now want an "instance_2", I suppose I could do:
-
- eval "package instance_2";
- %_instance_2 = %_main;
-
- or
-
- %_instance_2 = %_instance_1;
-
- to easily inherit what "instance_1" was doing...
-
- The tricky part (as if this isn't bad enough!) seems to be in
- going from one instance to another. I can't just say "package" again,
- since it clobbers all of the vars in the package. At this point I'm
- starting to run out of steam (other than the idea of caching away the
- symtab of an instance so that I can grab it back later). I think
- Tom C. has something like this going on in Plum for mail folders. I'm
- thinking of applying it to pretty much the whole script though. Any ideas?
- I'm also somewhat concerned about how portable this might be. A little
- experimentation on a SPARC is fine, but I want to get a little feedback
- about possible hiccups on other platforms.
-
- Daniel
- --
- Daniel Smith, Autodesk, Sausalito, California, (415) 332-2344 x 2580
- Disclaimer: written by a highly caffeinated mammal
- dansmith@autodesk.com dansmith@well.sf.ca.us
-
-