in reply to Re: Nested hashes, non-unique names
in thread Nested hashes, non-unique names

One other stupid question...

I realized within the past day that the layout key sometimes changes. It was "k-p12h-n13-1" when I first posted, but since then they changed it to "k-p12h-n14-1".

Having looked at some old data, it seems as though the one part which never changes is "k-p12h-n".

I've been trying to modify the grep above to match that, but am having no success. Have tried umpteen different ways so far, but none have worked. (I can change the operator from "eq" to "=~" without breaking it, which seems to be a step in the right direction. But if the pattern isn't contained within single quotes it breaks, and I can't seem to use a regex within single quotes, nor get it to match a partial string within single quotes.)

grep /k-p12h-n/ =~ $_->{'layout-key'}

was the first thing that came to my mind, but that's clearly not correct. I know I'm missing something here, I'm just not seeing what...

Replies are listed 'Best First'.
Re^3: Nested hashes, non-unique names
by choroba (Cardinal) on Mar 19, 2014 at 14:24 UTC
    The string to match goes on the left, the pattern on the right:
    grep $_->{'layout-key'} =~ /k-p12h-n/,
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      Simple as that. Thanks again!