in reply to Changing data in one directory
The glob function will exclude dotfiles for you. It would be a good idea to test that each filename is a regular file, and is readable and writable to you. There is a handy set of run flags in perl for sed-like operations like this, so I'll show how to call up a second perl process to do the work,
That omits your change counting. The odd looking error handling in system...; is because of the inverted logic of its return value.my $dir = "/perl/bin/ThisDirectoryHere"; my @files = grep { -f and -r _ and -w _} glob "$dir/*"; system '/usr/bin/perl', '-pi', '-e', 's/oldword/newword/gi', @files and die $?;
The alternative is to set up a loop on @files as you have, opening each to read and a new file to write. Read, substitute, write, and when done, rename the new file to the old name. File locking (flock) may be advisable.
After Compline,
Zaxo
|
|---|