I want to cycle through a bunch of modules that have credentials and site URLs .. I have this working OK, but it seems that I'm doing it in a much complicated way than I should. Feedback would be appreciated.
This script illustrates how I plan to cycle through the credential modules:
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; { my @variables = qw/User Password Url Prefix/; foreach my $module ( qw/Foo Bar/ ) { eval "use ABCXYZ::$module"; # Foreach loop for illustration only .. could be replaced # with a map .. my %values; foreach my $var ( @variables ) { $values{ $var } = eval '$' . join ( '::', 'ABCXYZ', $module, $var ); } # Call subroutine with values hash here .. } }
The goal is to be able to call a routine with individual site credentials for order processing. Is there a more Perl-ish way of accomplishing this? Credential modules look like this:
The credentials are stored like this so that the processing scripts can be checked into github without credentials leaving the customer site.package ABCXYZ::Foo; use Exporter; our @Export = ( $User $Password $Url $Prefix ); our $User = 'Joe'; our $Password = 'Secret123'; our $Url = 'www.example.com'; our $Prefix = 'EX'; 1;
In reply to Accessing module variables by talexb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |