use strict; use warnings; use Getopt::Long; use Data::Dumper; my $log; my $account; my $href = {}; my $globalConfig = "globalConfig.cfg"; my $localConfig = "localConfig.cfg"; GetOptions ( "log=s" => \$log, "account=s" => \$account ); &getEnv($globalConfig); &getEnv($localConfig); print Dumper $href; exit; sub getEnv { # my $href = shift(@_); my $file = shift(@_); unless ( -e $file ) { print "Could not find $file \n"; exit(1); } open ( FILE , "< $file" ); while ( ) { chomp; next if $_ =~ /^\#/; my ($key, $variable) = split(/=/,$_,2); if ( $variable && $key ) { $variable =~ s/\s+//g; $key =~ s/\s+//g; $href->{config}->{$key} = $variable; } } close FILE; }