Brett W. McCoy wrote: >On Fri, 25 Jan 2002, IT Workflow - Terry Honeyford wrote: > >>I am trying to print out only the lines that begin with Either "Unable to >>attach to", OR "Backup of" >>and append to the line "NOT OK" or "OK" depending on which match I get >>Here is the offending bit of script... >> >>open (FILE, "</path/to/file")or die "can't open file $!"; >> >>while (<FILE>){ >>chomp; >>if (m/^Unable to attach to/){ >>$line .= "$_ \t NOT OK"; >>}elsif{ >>(m/^Backup of/){ >>$line .= "$_ \tOK"; >>} >>} >>Print $line; >> >>if I dont chomp $_ then I get the OK/Not OK message on the line below, >>if I do use chomp I get the first 7 characters of the Original line then the >>"OK/Not Ok" the original line the continues as though the OK/Not OK has >>overprinted it! >> > >Just append "\n" to the line when you print it. > >-- Brett > Of course! I was totally stumped on this one. The chomp is stripping the \n (newline) but not the \r (carriage return). This caused the original line to print, followed by the carriage return which told the prompt to move the cursor to the begginning of the current line. It then printed over the line with "OK" or "Not OK". To fix this you just need to be sure to strip both \n and \r either using a regex or by making sure the special end of line variable is set to "\r\n" before you call chomp.
Now I can stop obsessing... And it wasn't even my problem! - Johnathan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]