title: Perl In place edit: Find and replace in X12850 formatted file
body: <p>I am new to Perl and cannot figure this out. I have a file called <strong>Test</strong>:</p>
  
  <pre><code>ISA^00^          ^00^          ^01^SupplyScan     ^01^NOVA           ^180815^0719^U^00204^000000255^0^P^^
  GS^PO^SupplyScan^NOVA^20180815^0719^00000255^X^002004
  ST^850^00000255
  BEG^00^SA^0000000059^^20180815
  DTM^097^20180815^0719
  N1^BY^^92^
  N1^SE^^92^1
  N1^ST^^92^
  PO1^1^4^BX^40.000^^^^^^^^IN^131470^^^1^
  PID^F^^^^CATH 6FR .070 MPA 1 100CM
  REF^
  PO1^2^4^BX^40.000^^^^^^^^IN^131295^^^1^
  PID^F^^^^CATHETER 6FR XB 3.5
  REF^
  PO1^3^2^EA^48.000^^^^^^^^IN^132288^^^1^
  PID^F^^^^CATH 6FR AL-1 SH
  REF^
  PO1^4^2^BX^48.000^^^^^^^^IN^131297^^^1^
  PID^F^^^^CATHETER 6FR .070 JL4SH 100CM
  REF^
  CTT^4^12
  SE^20^00000255
  GE^1^00000255
  IEA^1^00000255
  </code></pre>
  
  <p>What I am trying to do is an in place edit, dropping any value in the <code>N1^SE</code> segment after the <code>92^</code>. I tried this but I cant seem to make it work:</p>
  
  <pre><code>perl -i -pe 's/^N1\^SE\^\^92\^\d+$/N1^SE^^92^/g' Test
  </code></pre>
  
  <p>The final result should include the <code>N1^SE</code> segment looking like this:
  <code>N1^SE^^92^</code></p>
  
  <p>It worked when I just had the one line in the file: <code>N1^SE^^92^1</code>. But when I try to globally substitute in the entire file, it doesn't work</p>
  
  <p>Thanks.</p>