in reply to Wrapping requires in a package...

I'm not positive, but I think "do foo.pl" might be what you want. I think the do() command evals code in the current package.

However, having libraries that don't declare a unique package is terrible and you should really bitch and moan until those people fix their code.

Replies are listed 'Best First'.
(tye)Re2: Wrapping requires in a package...
by tye (Sage) on Sep 08, 2001 at 01:28 UTC

    Sorry, I forgot to mention that in my testing, do had the same inconsistant behavior as require that I report elsewhere in this thread.

            - tye (but my friends call me "Tye")
      I don't think it matters as long as the code he's do()ing doesn't have any use of __PACKAGE__ constructs or declare "package main" anywhere. The subs will be defined in the right package.

        But what if two different files do use vars qw( $level ); Will both be trying to share $main::level or will the variables be defined in the requested package like the subroutines (easy enough to check but I wasn't that interested in the problem). Are there more subtle problems? Someone reported to me that they were looking into all of this.

        But the real solution is to turn these files into real packages, which is what I hear is now being done. (:

                - tye (but my friends call me "Tye")