entysor has asked for the wisdom of the Perl Monks concerning the following question:

I have a master script that does this: require "filefinder" || die "couldn't open filefinder: $!"; and then performs the subroutines in filefinder. Is there any way to unrequire, or get rid of the code in filefinder after I have used it as I needed? I have to do this so subroutine names won't collide with those of the library files I also have to add in. Thanks!
  • Comment on Can I unrequire code to disable it's subroutines?

Replies are listed 'Best First'.
(tye)Re: Can I unrequire code to disable it's subroutines?
by tye (Sage) on May 26, 2001 at 00:36 UTC
    undef &subroutine;         - tye (but my friends call me "Tye")
Re: Can I unrequire code to disable it's subroutines?
by bikeNomad (Priest) on May 26, 2001 at 00:55 UTC
    Why don't you just make filefinder into a module? That way, you can choose what (if anything) to import into the main namespace.

    Another alternative might be to load filefinder into its own package, and use fully scoped names (you can alias the ones you want in the main package:

    package FileFinder; require "filefinder" || die "couldn't open filefinder: $!"; package main; FileFinder::someSubroutine();
Re: Can I unrequire code to disable it's subroutines?
by arturo (Vicar) on May 26, 2001 at 00:14 UTC

    Not to my knowledge, but you can always put the routines from your library files into a specific package and call them by their fully qualified names. Or: make FileFinder into an object, which won't require importing its methods, or do the namespacing trick with filefinder.pl