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

O' great monks, I have a fairly large perl project that I need to put into a form that can be easily navigated. I wrote another perl script that does a shallow parse of my large perl project using regexes and coverts it into webpages where each call to a subroutine has a link to the definition of that subroutine. My problem is that several of the objects that I have defined for this project have member functions with the exact same name. When I run my html generating script I have no way of knowing which type of object is being used. For example:
sub myfunction{ my($object1,$object2)=@_; print $object1->to_string(); print $object2->to_string(); }
In these cases I have to manually change links to the correct subroutine definition (my script defaults to whatever subroutine was defined last). Is there anyway to get around having to do this? Is there some module that I could use that could figure out which type of object a subroutine is being called by?

Replies are listed 'Best First'.
Re: Browsing Perl Code
by hardburn (Abbot) on Feb 03, 2003 at 16:41 UTC

    I'd use Exuberant Ctags (external link) to do the actual parsing of the Perl source file. The tags definition file should be a lot easier to parse than Perl code.

Re: Browsing Perl Code
by Hofmator (Curate) on Feb 03, 2003 at 17:00 UTC
    In general, your question can't be answered because you know only at run-time which function gets called. Perl is a weakly typed language - anything could be in $object1 and $object2 and only in very special cases will you be able to figure that out.

    Even in strongly typed languages you can't say for sure which method gets called at compile-time because the method calls are dynamically bound, that's one of the things OO is all about.

    -- Hofmator