Formula::State::$state
####
sub calculate_xyz {
my ($x, $y, $x, $state_variance) = @_;
$state_variance //= 1;
return (($x + $y) / $z) * $state_variance;
}
####
... calculate_xyz($x, $y, $x) ... # Use standard value
... calculate_xyz($x, $y, $x, 1.5) ... # Add 50% to standard value
... calculate_xyz($x, $y, $x, 2) ... # Double standard value
####
BEGIN {
my $state = ... get state from somewhere (e.g. $ARGV[0]) ...
require "Formula/State/$state.pm";
"Formula::State::$state"->import(@optional_arguments);
}
####
$ alias perle
alias perle='perl -Mstrict -Mwarnings -Mautodie=:all -E'
$ perle 'BEGIN { my $x = $ARGV[0]; require "List/$x.pm"; "List::$x"->import("uniq") } my @u = uniq (1,1,2,3,3,3); say "@u"' Util
1 2 3
$ perle 'BEGIN { my $x = $ARGV[0]; require "List/$x.pm"; "List::$x"->import("uniq") } my @u = uniq (1,1,2,3,3,3); say "@u"' MoreUtils
1 2 3
####
$ perle 'BEGIN { my $x = $ARGV[0]; require "List/$x.pm"; "List::$x"->import("first") } say first { not $_ % 2 } 1, 2, 3' Util
2
$ perle 'BEGIN { my $x = $ARGV[0]; require "List/$x.pm"; "List::$x"->import("first") } say first { not $_ % 2 } 1, 2, 3' MoreUtils
Could not find sub 'first' exported by List::MoreUtils at -e line 1.
BEGIN failed--compilation aborted at -e line 1.