in reply to Perl Modules
It is terribly difficult to read your post as is, so I didn't. However, I've put together an example of what I think you're after. The first file is the script itself, which uses the A module (A.pm in the local directory). The A module exports a single function, and this module includes the B module which also exports a single function. It in turn uses the C module, which exports a single function, which prints an incoming string.
a_func() takes a single parameter, a string. It passes it to b_func(), which then passes it to c_func() which then prints it to the screen.
The flow is like this:
script -> A::a_func("str") -> B::b_func("str") -> C::c_func("str") # c_func is what prints the data
The script:
use warnings; use strict; use lib '.'; use A qw(a_func); a_func("a string");
The A module:
package A; use lib '.'; use B qw(b_func); # load the 'B' package use Exporter qw(import); our @EXPORT_OK = qw(a_func); sub a_func { my $str = shift; b_func($str); } 1;
The B module:
package B; use lib '.'; use C qw(c_func); use Exporter qw(import); our @EXPORT_OK = qw (b_func); sub b_func { my $str = shift; c_func($str); } 1;
The C module:
package C; use Exporter qw(import); our @EXPORT_OK = qw(c_func); sub c_func { my $string_to_say = shift; print "$string_to_say\n"; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Modules
by jamroll (Beadle) on Jun 20, 2017 at 17:51 UTC | |
by stevieb (Canon) on Jun 20, 2017 at 18:34 UTC | |
by jamroll (Beadle) on Jun 20, 2017 at 20:18 UTC | |
by stevieb (Canon) on Jun 20, 2017 at 21:23 UTC | |
by jamroll (Beadle) on Jun 20, 2017 at 22:03 UTC |