in reply to Perl Config::Simple with %hash or @array
is it possible to combine Blocks with hashes or arrays?It is possible to combine blocks with arrays but not with hashes, however it is easy to convert an array to a hash.
For an array you just need to separate the values with a comma:
You can then process that:[requirements] array=bar,baz hash=bar,1,baz,2
Output:my $ary = $config{'requirements.array'}; my $hary = $config{'requirements.hash'}; # convert array reference to hash my %hash = @$hary; print "ARRAY:\n"; for my $item (@$ary) { print "$item\n"; } print "HASH:\n"; for my $key (keys %hash) { print "$key => $hash{$key}\n"; }
ARRAY: bar baz HASH: bar => 1 baz => 2
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl Config::Simple with %hash or @array
by thanos1983 (Parson) on Apr 30, 2014 at 08:47 UTC |