On Tue, Jul 8, 2008 at 10:52 AM, Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote: > Rob Dixon wrote: >> >> Noah wrote: >>> >>> Rob Dixon wrote: >>>> >>>> Then I guess you are processing a file that originated on a Windows >>>> system? >>>> Windows text files have a <CR><LF> sequence at the end of each record, >>>> whereas >>>> Unix files have just <LF>. <CR> is control-M, which is why vim is >>>> showing ^M at >>>> the end of the line. >>>> >>>> What you need to do it to remove all whitespace from the end of lines >>>> after you >>>> read them (from both the template and the config files) like this. >>>> >>>> @config_file_lines = <INPUT>; >>>> s/\s+$// foreach @config_file_lines; >>>> >>>> That will remove and CR or LF characters as well as spaces and tabs (and >>>> FFs >>>> actually) so that there are no line terminators at all and the record >>>> contents >>>> can be compared properly. >>> >>> okay the necessary line feed at the end of the line is disappearing. >>> would it be better to something like: >>> >>> @config_file_lines = <INPUT>; >>> s/\s+$/\n/ foreach @config_file_lines; >> >> The newline is only necessary if you perform the substitution only on one >> set of >> records. If you also apply it to those from the template file as I said >> then it >> will work fine. > > I don't get it. The OP wants to compare lines. How would that work fine if > there are no lines to compare? >
The file is split into lines, and each line stored as an element of @lines. *Then* the crlf is stripped from each element of @lines. HTH, -- j -------------------------------------------------- This email and attachment(s): [ ] blogable; [ x ] ask first; [ ] private and confidential daggerquill [at] gmail [dot] com http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org values of β will give rise to dom!