I have a Perl script. If it was called direct from the command line, I want to run sub main.
If it was called using require, I want to do nothing and wait for the caller script to call sub job at it’s leisure.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s a recommended Perl solution for code which needs to be runnable from a script as well as a perl module.
It’s usually called “modulino”, which can be used as Google or SO search term to find how-tos.
Here’s one how-to with reference links:
Perl script usable as a program and as a module