POV-Ray : Newsgroups : povray.off-topic : Use case : Re: Use case Server Time
29 Jul 2024 20:24:50 EDT (-0400)
  Re: Use case  
From: Warp
Date: 26 Aug 2011 12:17:48
Message: <4e57c72c@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> >> The right tool for the job would obviously be some sort of file
> >> comparison tool - which Perl isn't.
> >
> > Do you need to make the same change in each file? If so, Perl or sed, or
> > awk are perfect tools for the job.
> >
> > I don't see where diff comes into play...

> diff compares files and automatically figures out what changed.

> patch automatically applies those changes to other files.

> ...which neatly describes the exact thing I'm trying to do.

  That still doesn't explain what exactly is it that you want to do.

  If you change line 35 in one file, should line 35 be changed accordingly
in all files? What if that line is completely unrelated in the other files?
How should the script find the correspondent line in the other files? What
if some of the other files do not have any such line, or have several that
match the criterion? (And that's assuming the script could figure out the
criterion you are thinking. How can it know that?) How do you even define
this criterion for matching the "same" line in all the files?

  Your "make the same edit in all files" is still *way* too vague to give
any kind of rational answer. As you describe it, it just sounds like what
you want is for the computer to "do what I want", without you even knowing
yourself how to express clearly and unambiguously what it is that you want
(something I find rather strange from a computer programmer).

  If what you mean is that "all the files have key-value pairs in them
and I want all the values at certain keys changed", that sounds exactly
like a search&replace task: Search for the key, change the value.

  If what you want is "parse this file for key-value pairs, and then check
all the other files, and whenever there's the same key as in the first file,
change the value to be the same", that sounds like you want to write a
program to do that. 'diff' and 'patch' have no concept of keys and values.
They are not syntax parsers. (This is especially so because often such
key-value configuration files have *sections*, and the same key could well
appear in different sections, with a different meaning. You can't do this
change on a line-per-line comparison basis. You have to parse the entire
sections.)

-- 
                                                          - Warp


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.