in reply to [Solved] Parameter injection for testing
my $param = shift;
$param is a lexical variable so you have no way of getting at it. Make it a global variable and you can get at it from the outside:
our $param = shift;
... or even better, consider initializing the parameters from @ARGV, and doing so only in main, or passing @ARGV explicitly to main:
say main(@ARGV) unless caller(); sub main { my( @args ) = @_; GetOptionsFromArray( \@args, ... ); $param //= 'World'; return 'Hello ' . $param; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Parameter injection for testing
by davies (Monsignor) on Aug 24, 2022 at 15:17 UTC |