... back to the original problem of replacing the hash keys with the hash values.

You say you know your translation hash is being built properly, so since I'm about to turn into a pumpkin, let me leave you with the following code to think about:

use warnings FATAL => 'all'; use strict; my %hash = ( 'nc7-52' => 'C_fraterna', 'mi9-87' => 'D_whatever', ); my ($search) = map qr{ $_ }xms, join ' | ', keys %hash ; print "search regex: \n", $search, "\n\n"; # FOR DEBUG print "output: \n"; while (<DATA>) { my $line = $_; $line =~ s{ \A ($search) (?= :) }{$hash{$1}_$1}xms; print $line; } __DATA__ nc7-52:p39|read1|1|19|296|0.0642 ia1-23:p42|read1|1|19|296|0.0642 mi9-87:p77|read1|1|19|296|0.0642
Play with it and get the substitutions right, and you can move on to the business of writing the edited file tomorrow.


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.