On Wed, Jul 25, 2001 at 08:46:21PM +0200, Birgit Kellner wrote:
> --On Mittwoch, 25. Juli 2001 09:27 -0800 Michael Fowler 
> <[EMAIL PROTECTED]> wrote:
>
> Assume $targetdir holds "/home/somedir" and $2 holds 
> "/anotherdir/yetanotherdir/";
> So, to check if the dir /home/somedir/anotherdir/yetanotherdir exists, I 
> would use:
> 
> chop($2); # remove final trailing slash

Not only is this not safe (what if $2 doesn't have a trailing slash?), it
can't be done; the regex memory variables ($1, $2, $3, etc.) are read-only.

It's really irrelevant, though; the trailing slash can be left in, none of
the operators that deal with paths care about multiple slashes.  This is
true for Unix and the special path handling in Windows; I'm not sure of the
various other operating systems.


> $subdir = "$admindir$2";
> unless (-e "$subdir") {
>       mkpath($subdir);
>       }

The question is really moot, mkpath doesn't have a problem if the directory
already exists, so you don't need to check it.

    
Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to