in reply to mkpath (and rmtree) throw strange error when used in CGI

It'd likely be more helpful if you actually showed the text you're getting... without that, I just have to imagine it.

Most likely problem in CGI when dealing with the filesystem is write/execute permission. Remember that the CGI app is usually not running as your user, but as whatever apache drops privileges to (apache and nobody are common choices, but could be anything). So if that user doesn't have permission to make the directory, it will fail.

What you are probably seeing is mkpath's failure. According to the docs, it'll use Carp::croak - so trap it with eval:

unless (eval { mkpath($dir); 1 }) { show_error_page("Couldn't create $dir: $@"); }
But that's just a guess.

Replies are listed 'Best First'.
Re^2: mkpath (and rmtree) throw strange error when used in CGI
by ibmman (Novice) on Feb 10, 2009 at 22:17 UTC
    Hmm, it might be worth trying to see if perhaps there's something sneaking into the array with the paths that shouldn't be there- but I've displayed every element in the array before and it looks okay. I'm also not running mkpath when a directory already exists.
      Doesn't mean you're not fooling yourself, hexdump
      print "<pre>\n"; for my $i ( 0 .. $#foo ){ print "$i)", unpack('H*', $foo[$i]),"\n"; } print "</pre>\n";