$hash= { 'test_link_color' => '#31e500', 'test_widget_header_color' => '#c6b989', 'header_textcolor' => 'blank', 'test_menu_color' => '#004d59', 'test_widget_color' => '#eee3b7', 'custom_logo' => 5, 'test_headline_color' => '#7b0706', 'custom_css_post_id' => -1, 'header_image_data' => bless( { 'height' => 250, 'width' => 1140, 'attachment_id' => 9, }, 'PHP::Serialization::Object::stdClass' ), 'test_article_background_color' => '#ceddd2', 'test_menu_text_color' => '#ffffff', 'test_widget_title_color' => '#ffffff', 'test_menu_hl_color' => '#a74d3d', 'nav_menu_locations' => { 'menu-1' => 2 }, 'background_color' => 'ffffff', 'test_text_color' => '#000000' }; #### my %colors = map { $_ => %$hash{$_} } grep { $_ =~ /color$/ } keys %$hash; #### %colors = ( 'ffffff' => 'test_text_color', 'test_article_background_color' => 'test_article_background_color', 'blank' => 'test_menu_color', 'test_menu_text_color' => '#ffffff', 'test_text_color' => '#000000', 'background_color' => 'background_color', '#31e500' => 'test_widget_header_color', 'test_widget_title_color' => 'test_widget_title_color', '#eee3b7' => 'test_headline_color', '#ceddd2' => 'test_menu_text_color', 'test_menu_hl_color' => '#a74d3d', '#ffffff' => 'test_menu_hl_color', 'test_link_color' => 'test_link_color', 'test_widget_header_color' => '#c6b989', 'test_widget_color' => 'test_widget_color', 'test_headline_color' => '#7b0706', 'header_textcolor' => 'header_textcolor', 'test_menu_color' => '#004d59' );