pattern matching on directory names
Posted on 2000-03-02
(this is my second week in perl, please be gentle and verbose)
I have an array of filenames built recursively on the ARGV's given like so -- movefiles.pl docs temp ftp
I'd like to be able to pull each directory (and however many nested subdirs) from each array element (while leaving the array intact).
I have this code from another question:
@Bits = split /AA/, $filename;
foreach $Chunk (@Bits)
But I'm not looking for AA, I need to split on / -- and the compiler really doesn't like it when I do that.
# this part is just for trivia
Afterward, I want to create each dir if necessary, but is there a worse performance hit for trying to verify its existence with a
mkdir ($MoveDir, 777)
unless (opendir VAR2, "$MoveDir");
or to just try to create the dir and fail?