Perl: the Markov chain saw | |
PerlMonks |
Re^2: In place search and replace with a hashby hkates (Novice) |
on Dec 28, 2014 at 03:29 UTC ( [id://1111513]=note: print w/replies, xml ) | Need Help?? |
Anomalous, you're right. As I wrote in my original post, I have never actually used s/foo/bar other than in a one liner. I was looking for a way to find and replace strings in a file without writing to a new output file and when the replacement strings are not the same length as the sub-strings that are replaced. Clearly I am not doing this the correct way, and if there is a correct way, I haven't been able to find/understand it yet. What I want is to open a file and if a line is: 'nc7-52:p39|read1|1|19|296|0.0642' and change it to: C_fraterna_nc7-52 using a hash where $hash{nc7-52}=C_fraterna_nc7-52 Update: From this example it looks like it would be easy to print to output, but some lines in the file will not be modified and I still want to preserve them. sorry, this thread may be a bit out of control since I had too many problems to begin with
In Section
Seekers of Perl Wisdom
|
|