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

Am going through a code, am just wondering where does the function resides. ( this program works fine, accesses that function, and gives the output as expected ).

There is a function call like, $self->{YYYY}->function_name();

This function is not available anywhere. No use modules. Inheritance also, they have @ISA used as,
@ISA         = qw(Exporter);

Can somebody guide me further ?

Replies are listed 'Best First'.
Re: where does the function defintion resides ?
by cdarke (Prior) on Jul 23, 2010 at 13:18 UTC
    Trace back to where $self was defined, and the hash key YYYY. You say "no use modules", but (excuse me if you already know this) modules can also be included using require or the -M command-line option and a few other screwy ways, like export_fail and autoload.

    If they have set @ISA = qw(Exporter) then that looks like the code you are looking at is inside a module already, otherwise why export?
Re: where does the function defintion resides ?
by ikegami (Patriarch) on Jul 23, 2010 at 15:33 UTC

    $self->{YYYY}->function_name();
    is
    ( $self->{YYYY} )->function_name();

    So first find out what $self->{YYYY} contains. If it's an object, printing it out (or printing out ref($self->{YYYY})) should tell you what class it belongs to. Alternatively, if it's a file handle, it's automatically associated with the Filehandle or IO::File package

Re: where does the function defintion resides ?
by jethro (Monsignor) on Jul 23, 2010 at 14:08 UTC
    Another possibility is that if your function_name is either 'isa', 'does'. 'can' or 'version', then the function is defined in the class UNIVERSAL. Every class in perl inherits from UNIVERSAL.
Re: where does the function defintion resides ?
by Anonymous Monk on Jul 23, 2010 at 13:17 UTC
    AUTOLOAD