in reply to DWIM: autoloading classes

Are you reinventing autouse through a lack of awareness, or a deliberate disgust with the interface? {grin}

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: DWIM: autoloading classes
by Ovid (Cardinal) on Sep 17, 2003 at 02:56 UTC

    Actually, I didn't know about that module, but what I was looking at is still different. Even the Class::Autouse is considerably different:

    use Class::Autouse qw{CGI Data::Manip This::That};

    Mine finds all classes below a top level namespace. For example, if you have Foo::Bar, Foo::Bar::One::More, Foo::Bar::Two::Bad and Foo::Bar::Three::SaCharm, you could do make all of them "autoused" with this:

    use Class::WhenNeeded 'Foo::Bar'; my $bad_luck = Foo::Bar::Two::Bad->new; # or possibly use Class::WhenNeeded 'Foo::Bar' => 'no_top_level'; my $good_luck = Three::SaCharm->new;

    Perhaps my response to Abigail-II will clear it up. (Or perhaps it won't :)

    Cheers,
    Ovid

    New address of my CGI Course.

      It looks like Class::Autouse has a "superloader" option that will load any class as soon as you call a method on it.

        I think liz's point about being careful about a potential security problem would be greatly magnified by the autouse functionality, though I confess that I have the same problem in my own sample code, though perhaps on a smaller scale. I wonder if it's safe to publish with a healthy "disclaimer". Hmm ...

        And thanks for the pointer. I hadn't seen that but I must confess that it looks very interesting.

        Cheers,
        Ovid

        New address of my CGI Course.