in reply to Re: Parsing an Array of Hashes, Modifying Key/Value Pairs
in thread Parsing an Array of Hashes, Modifying Key/Value Pairs

> if ( !grep(/$key/, @keysToKeep) )

Careful! Without anchors you'll also match on substrings, so better /^$key$/.

Anyway try to avoid regexes when possible and use eq

if ( not grep { $key eq $_ }  @keysToKeep) )

Cheers Rolf

( addicted to the Perl Programming Language)

edit

corrected code

Replies are listed 'Best First'.
Re^3: Parsing an Array of Hashes, Modifying Key/Value Pairs
by librarat (Novice) on May 12, 2013 at 21:11 UTC
    Good catch!
    When I'm playing with regex, I use GSkinners test suite (as I'm without a doubt, no wizard)
    The regex fail in the OP was very much glassed over by me as I knew it wasn't doing anything that was getting me towards my end goal.
    http://gskinner.com/RegExr/

    -- Libra