I dont understand exaclty what are you trying to do...

If you want to do a regex over the keys of a hash and
get some part of them using backreferences, then
something like

@p=map /(\w+)/g, keys %nerf;

would work; it takes all keys, get all secuences of
word chars from each key and return the array with all
the parts. Or, for instance, if you want only the values
whose keys match some regex, you could do
@v=map $nerf{$_}, map /^(\d+)$/, keys %nerf;

(this gets all values from %nerf where the key is a number)
Or even, get a new hash with the subset of the previous
hash pairs where the key matches the regex:
%sh=map {($_=>$nerf{$_})} map /^(\d+)$/, keys %nerf;

Now, if what you want is to apply a regex to $_ or other
string, take all the backreferences for it, and then
get the values from the hash whose key its one of those
backreferences, something like
@v=map exists $nerf{$_} ? $nerf{$_} : (), /(\w+)/g;
%sh=map exists $nerf{$_} ? ($_=>$nerf{$_}): (), /(\w+)/g;

(in this case, that gets all words from $_ and gives you
the array of values of the subset of the hash)

Now this is obfuscated, right? :-)


In reply to Re: Contexts for regex evaluations by Anonymous Monk
in thread Contexts for regex evaluations by neshura

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.