in reply to Searching and Replacing file content within directory
Even on Windows, you can use / instead of \ for path separators. Makes things juts a bit more readable.
That said, you should not be modifying files in-place. It's dangerous and not easy to do right. (Tie::File might make it doable.)
Normal behaviour is: a) rename file to $_.old; b) open $_.old for read and $_ for write; c) loop through read-handle : modify line, write line; d) close filehandles; e) possibly delete old file (if you don't, then deleting it before (a) is a good thing, just in case it's still around).
Note that as far as I can see, you're not writing anything back to the file, which, as I said, would be difficult to get correct anyway, so don't do it. But I wouldn't expect ANY files to be updated with your code.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Searching and Replacing file content within directory
by MishaMoose (Scribe) on Nov 12, 2010 at 16:15 UTC |