Page 1 of 3 123 LastLast
Results 1 to 10 of 21

Thread: Perl: Oposite of require

Hybrid View

  1. #1

    Perl: Oposite of require

    Anyone know how to un-require libraries in perl? Like remove them during run time in favor of other libraries if the usre so chooses? ???

  2. #2

    Re:Perl: Oposite of require

    Basically module swapping.

  3. #3

    Re:Perl: Oposite of require

    Instead of loading one then asking if the user wants to switch, how about just asking the user which one he wants, then loading it?

  4. #4

    Re:Perl: Oposite of require

    [quote author=Feztaa link=board=9;threadid=4291;start=0#42840 date=1027580129]
    Instead of loading one then asking if the user wants to switch, how about just asking the user which one he wants, then loading it?
    [/quote]

    Thats what I am doing at the present time, and I guess it makes sense since people use 1 package manager (why would someone be switching between all the package managers on the same OS!).

  5. #5

    Re:Perl: Oposite of require

    Well, my perl reference book doesn't mention anything about being able to unrequire stuff, so I guess you can't.

    What is it that you're requiring? Self-written definitions for how to use different package managers, or some external perl modules that you've found?

    If they're self written, you could probably duplicate all the files and change them so that they undo whatever the original copy did. IOW, you could have "require aptget;" for using apt-get, and then "require unaptget;" to undo whatever "require aptget;" did.

  6. #6

    Re:Perl: Oposite of require

    [quote author=Feztaa link=board=9;threadid=4291;start=0#42963 date=1027620157]
    If they're self written, you could probably duplicate all the files and change them so that they undo whatever the original copy did. IOW, you could have "require aptget;" for using apt-get, and then "require unaptget;" to undo whatever "require aptget;" did.
    [/quote]

    They are home made modules (yummm). Thats not a bad idea, but how would I go about writing a removing function like that. It seems like a catch22 since requiring an un-packagesys would have the same problems as just trying to load another module over it. :-\

  7. #7

    Re:Perl: Oposite of require

    Well no, you just make an unaptget module that undoes whatever the aptget module does.

    What do these modules, do, anyway? Do they just define some functions and set some variables? If so, this would be really easy. The aptget module could define the variable $packagesys to be "apt-get", and define the function "install" to install a package with apt-get. Then the unaptget module would define the variable $packagesys to be "none", and undefine the function. Actually, you probably wouldn't need an undo module for each other module, you could probably get away with a single "nopackagesys" module that does it, or something.

  8. #8

    Re:Perl: Oposite of require

    How do I undefinc the function? Thats exactly what I need :-P.

  9. #9

    Re:Perl: Oposite of require

    Use undef. Function names are prefixed with &.

    Code:
    sub foo
    {
      print "foo\n";
    }
    
    foo();
    
    undef &foo;
    
    # Function 'foo' is no longer defined
    
    foo();

  10. #10

    Re:Perl: Oposite of require

    [quote author=Feztaa link=board=9;threadid=4291;start=0#43928 date=1028080851]
    Code:
    sub foo
    {
      print "foo\n";
    }
    
    foo();
    
    undef &foo;
    
    # Function 'foo' is no longer defined
    
    foo();
    [/quote]

    Of course! Why didn't I think of that! :P thanks!

Similar Threads

  1. Wireless NIC seems to require restart
    By axxis in forum Linux - Hardware, Networking & Security
    Replies: 1
    Last Post: 01-17-2007, 06:02 AM
  2. Perl and XML
    By coltrane in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 12-09-2004, 10:57 PM
  3. Perl Help
    By pwrhouse in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 04-06-2003, 11:57 PM
  4. perl question from a perl newb
    By tolstoy in forum Linux - Software, Applications & Programming
    Replies: 4
    Last Post: 09-06-2002, 01:16 AM
  5. What does WineX require?
    By airhead in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 08-03-2002, 03:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •