> cat TEST_PACKAGE.pm
package TEST_PACKAGE;
use base 'Exporter';
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(%TEST_HASH);
our %TEST_HASH;
$TEST_HASH{'TEST_KEY'} = 'TEST_VALUE';
1;
####
xterm> ./test.pl '/bin/touch $TEST_HASH{'TEST_KEY'}' # Would create a touchfile called TEST_VALUE
xterm> ./test.pl 'echo Test key contains $TEST_HASH{'TEST_KEY'}' # Would echo TEST_VALUE
####
> cat test.pl
#!/usr/bin/perl
my @command = @ARGV;
use TEST_PACKAGE qw(%TEST_HASH);
my $command_string;
for (my $i = 0; $i < scalar(@command); $i++ ) {
# Interpret each word in the command string and substitute known variables
$command_string = $command_string . " " . ( sprintf "%s", $command[$i] );
}
print "\nExecuting command: $command_string\n";
system "$command_string";
####
xterm> ./test.pl 'echo Test key contains $TEST_HASH{'TEST_KEY'}' # One of many trials, with varying escape characters tried
Executing command: echo Test key contains $TEST_HASH{TEST_KEY}
Test key contains {TEST_KEY}