MacPerl novice here, hoping someone can help me solve a problem. I'm running
MacPerl 5.6.1.
I've written a perl script to do batch updates on a bunch of files organized
in subdirectories. The script performs fine on files, looping through the
files and making the necessary updates, until it reaches a subdirectory in
the file list and tries treating it like a file. Then, of course, it dies.
So, to address this, I've added an -f test in the loop:
foreach $FileName (@AllFiles)
{
#if its a file, and not a directory, update it.
if (-f $FileName) {
[.....do updates.....]
}#end if file
}#end foreach
For some reason, this doesn't work. Regardless of whether $FileName is a
file or a directory, the script never executes anything inside the if{}
brackets. Nothing gets updated.
When I remove the -f test, the script will update files successfully until
it reaches a directory, when it dies.
I've also tried to test for directory instead:
if (-d $FileName) { next }
That doesn't work either.
Can anyone tell me what I'm missing?
Thanks.