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.