If someone can think of a more eloquent way of wording my title, please feel free to offer suggestions...I feel as though there is a word for what I'm trying to do, but it's escaping me.
Anyways, I've got a bunch of Perl scripts I've made and each one has a "usage()" method that essentially describes how to use the respective script. Now, I've also got a package that is utilized by each of these scripts (Flags.pm) which parses command line arguments for the script to use. What I want to do is have it so that the method called within Flags.pm (getArguments()) will try to determine if a particular flag is set (e.g. -help), and then from within that method call the parent scripts "usage()" method.
The idea is to avoid having to put the code to call "usage()" within each script, since each script will be calling it under the same conditions. I want my getArguments() in Flags.pm to handle it. Basically, I just want to achieve this...
Flags.pm
package Flags;
sub getArguments() {
usage();
}
1;
MyScript.pl
use Flags;
sub usage() {
print "Hello World";
}
$args=Flags->getArguments();
TL;DR: importing a Perl package for a script. want to call a method found in the script from within a method in the imported package.