Hi All,

I need to write a script that finds the uniq() function in code for a data manipulation language, and replaces it with hyd_uniq(). Here are some examples:

amend:  u= uniq( timetags.bin_start, s )
to:     u= hyd_uniq( timetags.bin_start, s )

amend:  u_ens=fit_energy(uniq(fit_energy(*,i),s),i)
to:     u_ens=fit_energy(hyd_uniq(fit_energy(*,i),s),i)

amend:  nxxi=n_elements(uniq(xxi(sort(xxi))))
to:     nxxi=n_elements(hyd_uniq(xxi(sort(xxi))))

Now, in order to get these examples I have already written the regular expressions that do the trick:

                s/\(uniq\(/\(hyd_uniq\(/;
                s/(\W)uniq\(/$1hyd_uniq\(/;

So my script reads a file, and pulls out the lines with uniq() in them, and then it passes these lines to a hash organized by file name. And then it goes through this hash, and prints out the filename and puts each line through the regular expressions given above to get the amend-to pairs that I printed up at the beginning of this message. So the script let me know just how much work there was to do. But I can't figure out how to write a script that will simply go through each of the files and change every

/\Wuniq\(/

to a
                /hyd_uniq(/

within the file! How do I slurp in a file and amend it? If this seems like an obscenely basic question, I apologize - I have no computer science training, just a copy of the Llama Book.

- Jason

/•
 •       If A equals success, then the formula is:
 •               X+Y+Z = A
 •       X is work.  Y is play.  And Z is keep your mouth shut.
 •                       -Albert Einstein
 •/

Reply via email to