- or download this
#!/usr/bin/env perl
...
print "Hello $name\n";
}
- or download this
# Main routine
sub main {
...
}
main();
- or download this
# Main routine
MAIN: {
...
say_hello($greeted);
}
- or download this
# Main routine
MAIN: {
...
exit(0);
}
- or download this
package My::Routine;
...
# Run the main routine only when called as a script
__PACKAGE__->main() unless caller;
- or download this
#!/usr/bin/perl
...
say_hello($greeted);
};
- or download this
#!/usr/bin/env perl
require 'script_with_main.pl';
print "Loaded script!\n";
run_main('Shakespeare!', 'perlmonks');
- or download this
$ perl test_test_main.pl
Loaded script!
Hello perlmonks
- or download this
use strict;
use warnings;
...
};
1;