Like this?

#!/usr/bin/perl use strict; use warnings; use feature qw/say/; while(<DATA>) { chomp; s/<([0-9A-F]+)>/"<" . hex($1) . ">"/eg; say; } __DATA__ JDW-HP 1MVWV93V7j2Hxsa0Ag6 24:00:00 SUBJECT_EXACT _Did you<A0>serve ou +r<A0>country? -New VA Home.Loan Program_ JDW-HP 1MVWV98Ddd4fLsa0Ag6 24:00:00 SUBJECT_EXACT Did.you.serve_our co +untry? New-VA Home<A0>Loan Program_

Output:

$ perl 1095788.pl JDW-HP 1MVWV93V7j2Hxsa0Ag6 24:00:00 SUBJECT_EXACT _Did you<160>serve o +ur<160>country? -New VA Home.Loan Program_ JDW-HP 1MVWV98Ddd4fLsa0Ag6 24:00:00 SUBJECT_EXACT Did.you.serve_our co +untry? New-VA Home<160>Loan Program_ $

For more on the s// (substitution) operator, see e.g. Regexp Quote Like Operators. The above substitution is fairly straightforward; it looks for angle brackets with one of more hex digits in them, and replaces them with the result of a snippet of code that gets evaluated for each match (hence the /e modifier to the regex). The /g modifier makes this a global operation so that all occurrences are given this treatment, not just the first.


In reply to Re: How do i replace one variable with another after searching for a pattern by AppleFritter
in thread How do i replace one variable with another after searching for a pattern by Niklaus Mikaelson

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.