... 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
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |