I'm not sure why this isn't working. I got a hash that looks like this:

$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' };

I want to filter out all keys that aren't a color property, so I have:

my %colors = map { $_ => %$hash{$_} } grep { $_ =~ /color$/ } keys %$h +ash;

I'm getting a result with they key/values all mixed up:

%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' );

I'm not sure what I'm missing here.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks


In reply to Hash filter one-liner not working as expected by nysus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.