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

Is Perl module similar to package in java ? I was going through a File::Find module. It feels like its just one big file. In java, a package consists of various classes, which are completely different files.
Like that, does Perl module contain different files or is it just one file containing numerous subroutines ?
In order to use any functionality, do I need to get complete module in a program and just use a particular subroutine ?
Do I need to create an ionstance of this entire class to use a subroutine ?

Thanks

Replies are listed 'Best First'.
Re: Perl module
by roboticus (Chancellor) on Oct 25, 2010 at 01:29 UTC

    manishrathi:

    It sounds like you need to spend a little time reading perldoc perlmod. But a couple of quick facts may help you out: In perl, a single file may contain *multiple* packages and/or classes. Similarly, a single package may be spread out over *multiple* files. A package need not have classes in it. In perl, packages and files may be flexibly divided in many ways. I'm by *no* means an expert on packages/modules in perl, so I'll leave the rest to the documentation and the more knowledgeable monks.

    ...roboticus

Re: Perl module
by aquarium (Curate) on Oct 25, 2010 at 04:15 UTC
    although there are OO perl modules, most are not OO. if a perl module needs to rely on other modules, it will generally have "use" directives at the top. Likewise, you'd "use File::Find" to make use of the functionality. Follow the module help as to how to use it.
    note though that you'll get more done in perl if you stop thinking all the time in terms of java OO analogies, as perl is not a strictly typed language like java. you'll get used to it, and enjoy the convenience and flexibility.
    the hardest line to type correctly is: stty erase ^H