I am facing a problem that require the reuse some of the functions within another Perl script. I am writing some test scripts. The test scripts are basically build on each other.
Say Script 1 does:
Some code to prepare the test. A. B. C. Some code to determine the success.
Then Script 2 does:
Some code to prepare the test. A. B. C. D. E. Some code to determine the success.
How can I reuse A.B.C of script 1 in script 2?
Calling script 1 from script 2 will not work because of the code to determine the success of the script. What is the best way to do this?
Thanks
Put the functions in a module and include that from both files.
See http://perldoc.perl.org/perlmod.html for more info.
Foo/Common.pm:
package Foo::Common;
use strict;
use warnings;
use parent 'Exporter';
our @EXPORT_OKAY = qw(frob borf);
sub frob {}
sub borf {}
1;
In some script or module, give or take a use lib
to get Foo/Common.pm in @INC:
use Foo::Common qw(frob borf);
frob();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With