albeit untested
Indeed ;-) A couple of things go wrong. @infiles is not initialised, but I guess this is left as an exercise to the OP. No, I really wanted to point out the use of exit, which is not what you want here, IIUC. exit terminates the program however deep you are in nested blocs. By using exit here, you stop the program once the first file has been renamed with a suffix. Instead of that, you want to proceed to the next file.
But next goes to the next iteration of the innermost loop. In our case, that would be the loop on suffices, not on files. So you'll need to use LABELS:FILE: foreach my $filename (@infiles) { ... if ( -e $ofilename ) { SUFFIX: for (@suffix) { if ( ! -e "$ofilename.$_" ) { ... next FILE; } else { ... } } } else { ... } }
--bwana147
In reply to Re: Re: File remaing and removal to a subdirectory
by bwana147
in thread File renaming and removal to a subdirectory
by Joes
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |