note
Laurent_R
Hi [nysus],
<p>
I'm surprised you don't get an error, as I am getting this with your code:
<c>
syntax error at colors.pl line 31, near "$hash{"
</c>
<p>
Anyway, changing your code line with the <c>grep</c> and <c>map</c> as follows:
<c>
my %colors = map { $_ => $hash->{$_} } grep { $_ =~ /color$/ } keys %$hash;
</c>
or like this:
<c>
my %colors = map { $_ => $$hash{$_} } grep { $_ =~ /color$/ } keys %$hash;
</c>
works for me. Your error seems to be in this: <c>%$hash{$_}</c> (in the <c>map</c>).
<p>
Output of <c>Data::Dumper</c> on the <c>%colors</c> hash:
<c>
$ perl colors.pl
$VAR1 = {
'test_menu_hl_color' => '#a74d3d',
'test_widget_color' => '#eee3b7',
'test_text_color' => '#000000',
'test_widget_header_color' => '#c6b989',
'test_menu_color' => '#004d59',
'background_color' => 'ffffff',
'test_article_background_color' => '#ceddd2',
'test_widget_title_color' => '#ffffff',
'test_menu_text_color' => '#ffffff',
'test_link_color' => '#31e500',
'test_headline_color' => '#7b0706',
'header_textcolor' => 'blank'
};
</c>
1231351
1231351