Writing perl module

Hi,

I'd like to create perl functions in separate file from my scripts.
Does somebody know if it's possible to create and use a perl module without compiling it ?

Thanks.

Yes. Perl modules have the extension ".pm" instead of the regular ".pl". Each Perl module is a class, in object-oriented programming (OOP) terms.

However, writing Perl modules require higher levels of Perl knowledge. In particular, you need to be proficient with references. Then, you can find more about writing Perl modules in the perlobj and perltoot manpage. But I guess these manpages are generally not easy to read. You should find a guidebook somewhere that talks about that. I can't tell you much about this here because this is not something I can explain with just a few lines of code and description.

But if you just want to keep your functions in a separate file without adopting an OOP style, the way I showed you in your previous thread (that is, use require() to source in an external file) is already sufficient. Best of all, that's easiest unless you need to adopt a pure object-oriented approach.

I just need to create few basic functions in separate files like this one:
# lib.pl
sub fonc
{
$arg1=$[0];
$arg2=$
[1];
print "arg1=$arg1, arg2=$arg2\n";
}
1;

I try to call this module in my main script but it seems not so easy :
# main.pl
use "lib.pl";
&fonc('test','ok');

You should use require "lib.pl" instead here, because use() is for Perl modules only.

sorry ... and THANKS.