Saturday, June 28, 2014

Usage of FindBin and Require Module

FindBin
We can use FindBin to locate the directory of our Perl script.
This can then be used, if required, to specify locations of required files stored relative to that script.

use FindBin qw($Bin);

# require the example.pl in the same directory as our script
require "$Bin/example.pl";

# require the other.pl file in the files/ directory
require "$Bin/files/other.pl"

RequireRequired files must end with a true value.
This is usually achieved by having the final statement of the file being:
1;

No comments: