The code example above was meant as a counter-example to what I understood LanX to be saying. Comments:

my %hash = ('$1' => 'oops', 'abc' => 'ok'); # create a hash 'abc' =~ m{ (abc) }xms; # capture a sub-string to $1 print qq{captured '$1'}; # show what that string is print $hash{'$1'}; # show effect of single-quotes: no interpolation
Had  $1 been used directly (as in $hash{ $1 }), the output would have been 'ok'. A more complete example:
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my %hash = ('$1' => 'oops', 'abc' => 'ok'); dd \%hash; ;; 'abc' =~ m{ (abc) }xms; print qq{captured '$1'}; ;; print 'single-quoted: ', $hash{'$1'}; print 'straight: ', $hash{ $1 }; " { "\$1" => "oops", "abc" => "ok" } captured 'abc' single-quoted: oops straight: ok


Give a man a fish:   <%-(-(-(-<


In reply to Re^5: In place search and replace with a hash by AnomalousMonk
in thread In place search and replace with a hash by hkates

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.