in reply to Passing Module parameters to another module
Do a require and import for package Bar:
package Foo; require Bar; sub import { my $class = shift; # first param is class name if (@_) { Bar->import(shift); # that's passed along # with 'use Foo qw(x);' } } # more stuff... 1;
package Bar; sub import { my $class = shift; if (@_) { my $x = shift; # passed from Foo warn "$class: got '$x' from ".caller()."\n"; # now do whatever you like with 'x' } } # more stuff... 1;
and then...
#!/usr/bin/perl use Foo qw(blorf);
...or even
$ perl -MFoo=blorflydick -e 1 Bar: got 'blorflydick' from Foo
|
|---|