#
# My email configuration file
#
pro_box = 1
[pro_box]
emails = person1@mycompany.com
emails = person2@mycompany.com
emails = person3@mycompany.com
emails = person4@mycompany.com
[default]
emails = person2@mycompany.com
emails = person3@mycompany.com
emails = person4@mycompany.com
####
#!/usr/bin/perl
use warnings;
use strict;
use AppConfig qw( :argcount );
my $config = AppConfig->new( {CREATE => 1,
GLOBAL => { ARGCOUNT => ARGCOUNT_LIST },
});
my $config_file = "email.conf";
$config->define("pro_box", { ARGCOUNT => ARGCOUNT_ONE } );
$config->file($config_file);
#
# Fetch pro box value
#
my $pro_box = $config->pro_box;
#
# Fetch arrays. Get rid of the "1" in @array[0].
#
my @pro_emails = @{$config->pro_box_emails};
shift @pro_emails;
my @default_emails = @{$config->default_emails};
shift @default_emails;
print "Pro Box = $pro_box \n";
print "\n" ;
my @mail_to = ($pro_box) ? @pro_emails : @default_emails ;
for (@mail_to ) {
print "My addresses are: $_ \n";
}
####
C:\Code>perl test_app_config.pl
Pro Box = 1
My addresses are: person1@mycompany.com
My addresses are: person2@mycompany.com
My addresses are: person3@mycompany.com
My addresses are: person4@mycompany.com