Search code examples
perlooppackageperl-module

Calling a subroutine in OOP Perl


When looking through some code I took over, I came across this line:

 my @files = My::Module::DB::raw_info->search_like(customer_handle => $config->{client}, feed => $config->{site}, arrival =>"$date")

I know that this returns an array from a package called My::Module::DB::raw_info.

What I'm not sure of (and I am just learning OOP), is what ->search_like refers to.

I didn't see that as a variable or as a subroutine in My::Module::DB::raw_info

Any hints would be appreciated. I'm only beginning to learn this stuff. It's like bathing in fire. (I know I'll be happier later though) Yikes!


Solution

  • The likely cause of your conundrum is that My::Module::DB extends some other class. Look for a block along the lines of

    use parent Some::Module;
    

    or

    BEGIN { extends Some::Module }
    

    near the top of My/Module/DB.pm

    Edit: As some commenters are helpfully pointing out below, there are a number of ways to subclass a Perl class, but these are probably the most common. (Maybe.)