Noah wrote:
> Rob Dixon wrote:
>> Noah wrote:
>>> Rob Dixon wrote:
>>>> Noah wrote:
>>>>
>>>>> let me put toether some bogus output files.
>>>>
>>>> You could just describe your output. Are you getting nothing at all? Or is 
>>>> it
>>>> showing all lines of both files? Or none from one and all from the other? 
>>>> Or
>>>> just more or fewer lines than you think is correct?
>>>>
>>>> Remember that non-printable characters (whitespace for instance) may not 
>>>> match
>>>> even though it looks the same: spaces and tab characters for instance.
>>>
>>> looks like nothing matches.   And when I open the files there is a "^M" 
>>> at the end of each line.  what would be the best approach to not pay any 
>>> attention to the "^M" - search/replace?
>>>
>>> When I capture the 'vim' man page and remove one line from one of the 
>>> files - things work fine when there is white space all over the place as 
>>> long as it matches.
>>
>> 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.

Rob

Rob

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to