package General;
use AutoLoader qw(AUTOLOAD);
use Exporter;
# functions your main script might want to import
our @EXPORT_OK = qw(
func1 func2 ...
);
1;
####
#!/usr/bin/perl
# file prog1.pl
# main program
my ($arg_a, $arg_b) = @ARGV;
; # ... more perl code
# end main
####
#!/usr/bin/perl
# file func1.al
package General; # the function must be compiled into its package.
sub func1 {
# main program
my ($arg_a, $arg_b) = @_;
; # ... more perl code
# end main
}
unless (caller) {
func1(@ARGV);
}
1; # <-- important!
####
package General;
# optionally put your subs here to predeclare them at package loading
sub func1 ;
1; # last line, important
####
#!/usr/bin/perl
use General qw(func1 otherfunc); # functions from General you want to call directly
my $result = func1($arg_a, $arg_b);