How do you write a module for Perl? In Python you can use:
# module.py
def helloworld(name):
print \"Hello, %s\" % name
# main.py
import module
module.
The most traditional way of setting up a module is as follows:
package Foo::Bar;
our @ISA = qw(Exporter); # Tells perl what to do with...
our @EXPORT = qw(sub1 sub2 sub3); # automatically exported subs
our @EXPORT_OK = qw(sub4 sub5); # exported only when demanded
# code for subs, constants, package variables here
1; # Doesn't actually have to be 1, just a 'true' value.
and as others have said, you can use it like so:
use Foo::Bar;