in reply to Symbol table globbing from object refs

Things like evaluating @ISA by hand *snip* seem so excessive that I reckoned someone must have thought of something.
Yes, examine @ISA (that's one of the reasons @ISA exists).

use Scalar::Util qw{ blessed };
use Module::Info;
use Data::Dumper;
use IO::File;
die Dumper( Module::Info->new_from_module( blessed( IO::File->new() ) ) );

update: also worth reading up on are Devel::ModInfo and Devel::Symdump.

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.

  • Comment on Re: Symbol table globbing from object refs

Replies are listed 'Best First'.
Re: Re: Symbol table globbing from object refs
by nothingmuch (Priest) on Nov 29, 2003 at 11:21 UTC
    I don't know how I ever missed Devel::Symdump! I searched before asking, but alas...

    I think it will do the trick with some @ISA snooping...!

    Thanks!



    -nuffin
    zz zZ Z Z #!perl
      ->can() doesn't handle AUTOLOADed methods, FYI.

        It does if you tell it to, which you should.

        Well, if it we're a means of getting responses for methods you don't know of it would be nice - most people that go around breaking it simply implement their own (see Class::Classless - i just submitted a patch (phew, a whole one line) for it to return code refs instead of 1, and Class::Object - i trust the documentation).

        The problem is that @ISA is not used, or perl's builtin method calling system is extended. That's the showstopper.

        Provided Autoload would provide (and export) a can, which either returns an anonymous subroutine that takes care of things, or actually loads the sub and returns a subroutine ref to that, It should pose no problem at all.


        -nuffin
        zz zZ Z Z #!perl
Re: Re: Symbol table globbing from object refs
by nothingmuch (Priest) on Nov 29, 2003 at 11:11 UTC
    But @ISA is usually lexical, which means i have to peek into it somehow. Ugly.
    @ISA is also very flexible - code refs and such. I'm not sure I want to implement something that's already been done - emulation is never 100%

    Morever, I can't guarantee this has a module, i'm expecting weird objects (classless ones, and so forth), so Module::Info doesn't work. At least not unless I use it on an opened scalar ref, containing B::Deparse's output. Very ugly.

    Last but not least, this is too resource intensive for such a simple job, IMHO.



    -nuffin
    zz zZ Z Z #!perl
      But @ISA is usually lexical, which means i have to peek into it somehow.
      Say what?!? If @ISA isn't a global/package variable, inheritance won't work. So it's never a lexical.
      So what? You requirements/expectations are completely unrealistic.
        I think they are pretty reasonable...

        PodMaster was absolutely right about Devel::Symdump, and I was totally wrong about walking @ISA. For some reason I thought it was lexical by default.

        I managed to find a solution that doesn't parse it's own code, and works under 20 lines of code, so i think it's realistic... =)

        Update: well... no classless objects, but...



        -nuffin
        zz zZ Z Z #!perl