in reply to Re: Problem with Renaming script
in thread Problem with Renaming script
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Problem with Renaming script
by graff (Chancellor) on May 22, 2003 at 17:59 UTC | |
Still, it might be worthwhile to try a different different approach to the problem. Something like: Things to note: (1) if you're going to declare lexically scoped variables with "my", declare each variable as you need it, in the block where it will be used, not globally (which kind of defeats some of the value of lexical scoping). (2) This approach uses a different strategy than your original -- since it knows it will need to rewrite every file anyway, it'll use a standard filtering approach, using "newhostname" to set the name of the output file where appropriate, then deleting the old file, and renaming the new one back to the original name if that wasn't supposed to change. That's not tested, of course, but assuming that you have already taken care of creating the appropriate list of file names for input to the process, and have the host names the way you want, this should take care of the rest of the task. (Personally, if it were my machine, I'd probably want to write all the output files to some separate directory, or at least keep the originals intact somehow, so I could confirm that worked okay before blowing away the originals...) | [reply] [d/l] |