Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!zaphod.mps.ohio-state.edu!van-bc!ubc-cs!uw-beaver!mit-eddie!media-lab.media.mit.edu!dnb From: dnb@meshugge.media.mit.edu (David N. Blank) Newsgroups: comp.lang.perl Subject: package switching Message-ID: Date: 1 May 91 15:52:54 GMT Sender: news@media-lab.media.mit.edu.MEDIA.MIT.EDU Distribution: comp Organization: M.I.T. Media Laboratory Lines: 26 Howdy- I've been having a great deal of fun with eval lately (as Tom and Randall both know) in an effort to make something I am writing really generic. I've hit another stumper on the subject: "package". If I want to be able to switch packages in a very generic way: sub blah{ package @_[0]; ... } &blah("bleh"); How do I do it? I have seen Randall use this idiom: > $ret = eval "package main; $action" but I would prefer not to stick the entire contents of a subroutine into one scalar variable. Is there some magic way to expand the scope of the package commands? Thanks. Peace, dNb -- David N. Blank o/ \ / \ / / \o M.I.T. Media Laboratory /# ##o # o## #\ E15-473F, (617) 253-2169 / \ / \ /o\ / |\ / \