use strict; use warnings; my %HR_config= (); my $cfgFile = "c:\\temp\\cfg.ini"; &initiliaze_config(\%HR_config, $cfgFile); my (@retVals) = &retrieve_config(\%HR_config); print "Values from the returned array:\t@retVals\n"; my @keys = keys(%HR_config); print "Keys from the populated hash:\t@keys\n"; my @hashVals = map ($HR_config{$_}, @keys); print "Values from the populated hash:\t@hashVals\n"; sub initiliaze_config { my ($HR_config,$file) = @_; open (my $fr, '<', "$file") || die "Unable to open configuration file: $file $!"; while (my $line = <$fr>) { $line =~ tr/\r\n//d; next unless $line; if ($line =~ /=/) { my ($key,$val)=$line=~ /^(.*?)=(.*?)$/; $$HR_config{$key} = $val; } } } sub retrieve_config { my $HR_config = pop(@_); my @values = (); foreach my $key (keys(%{$HR_config})){ my $value = $HR_config->{$key}; push(@values, $value); } return (@values); }