in reply to Find Replace

^M is a carriage return, represented by \015 or "\r" (less reliably). See Newlines in perlport. You could drop those easily with s/\r//g, but for the sake of argument I will assume you want to keep them. They are white space characters, so you can maintain insensitivity to them by ignoring trailing white space, e.g. /Cessna\d+\s*$/.

So you could do this in a one-liner like perl -pi -e '$i--;$i=2 if /Cessna\d+\s*$/;s/Down(?=\s*$)/Up/g if !$i' *.txt

Replies are listed 'Best First'.
Re^2: Find Replace
by SimTech (Initiate) on Dec 15, 2011 at 18:30 UTC

    Perfect. The one liner did just the thing

    Exactly what I needed it to do... But couldn't get the syntax.
    Thank you so much!

      Nuts - unpost.

      Seems I was able to make it work perfectly on a Unix system at the house with a file I made up to resemble the working version. At work on RH Linux - it does not work - as entered as a one line blurp from a command line - it will change all DOWNS to UP. Regardless of the aircraft type.

      I am reluctant to remove the ^M EOL, only because I have no control over the programs that are reading the files. Back to the drawing board -- thanks again for all the help - if anyone has another suggestion, I'm ready for it!

      Rob
        If the file(s) in question contain no 0x0a (line-feed) characters, then just change 0x0d (carriage-return) to line-feed "temporarily" to make your normal line-oriented processing easier, then change it back:
        perl -pe 'tr/\x0d/\x0a/' source.file | easy_line_filter | perl -pe 'tr +/\x0a/\x0d/' > edited.source.file
        The one-liner should have worked if your file matched the description. One possibility is that the regex I gave you matches all Cessnas, not just the 152. If that is the source of the issue, you can swap the "grab all digits" (\d+) clause with the literal you are looking for (152). Otherwise, you need to distribute the literal file, so I can grab it, warts and all, to check what's going on.
Re^2: Find Replace
by SimTech (Initiate) on Dec 16, 2011 at 06:23 UTC
    Thanks for the link... Very helpful for me. Still getting my butt kicked on the original post, but the link proves good reading.