in reply to search and replace on a line by line basis

This seems to work, though I'm sure there'll be prettier ways:
perl -lne 's/(?<=.{188})(\d{8})(?=.{16})/$1 eq "00000000"?next:"200201 +01"/e && print' original.txt > new.txt

Replies are listed 'Best First'.
Re: Re: search and replace on a line by line basis
by Roy Johnson (Monsignor) on Apr 15, 2004 at 14:02 UTC
    Using negative lookahead for the 00000000 case tightens it up:
    perl -lne 'print if s/(?<=^.{188})(?!0{8})(\d{8})(?=.{16})/20020101/' +original.txt > new.txt

    The PerlMonk tr/// Advocate