foreach my $Section (values %$config) { # $Section is a hash ref containing the values of the section, not the section name! foreach my $value (qw(files colors and other options that should be arrays)) { $Section->{$value} = [split /\s*,\s*/, $Section->{$value}]; } }