This seems like a really simple question but somehow my Google-Fu failed me.
What\'s the syntax for including functions from other files in Perl? I\'m looking for s
Perl require will do the job. You will need to ensure that any 'require'd files return truth by adding
1;
at the end of the file.
Here's a tiny sample:
$ cat m1.pl
use strict;
sub x { warn "aard"; }
1;
$ cat m2.pl
use strict;
require "m1.pl";
x();
$ perl m2.pl
aard at m1.pl line 2.
But migrate to modules as soon as you can.
EDIT
A few benefits of migrating code from scripts to modules:
require are only loaded at run time, whereas packages loaded with use are subject to earlier compile-time checks.