You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Scott Penrose <sc...@dd.com.au> on 2005/07/10 15:17:34 UTC

Real Directory

Now it seems obvious, but I can't find a reference to get the real  
directory of a URI.
Examples I have found on CPAN look something like this...

     my $uri = $r->uri;
     $uri =~ s|[^/]+$||;
     my $dir = $r->document_root . $uri;

The problem with the above is that it does not take into account  
Alias which could put the URI outside the document_root.

Any pointers?

Thanks

Scott
-- 
* - *  http://www.osdc.com.au - Open Source Developers Conference * - *
Scott Penrose
Anthropomorphic Personification Expert
http://search.cpan.org/search?author=SCOTT
scott@cpan.org

Dismaimer: While every attempt has been made to make sure that this  
email only contains zeros and ones, there has been no effort made to  
guarantee the quantity or the order.

Please do not send me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html

Microsoft is not the answer. It's the question. And the answer is no.



Re: Real Directory

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

Scott Penrose wrote:
> Now it seems obvious, but I can't find a reference to get the real 
> directory of a URI.
> Examples I have found on CPAN look something like this...
> 
>     my $uri = $r->uri;
>     $uri =~ s|[^/]+$||;
>     my $dir = $r->document_root . $uri;
> 
> The problem with the above is that it does not take into account  Alias
> which could put the URI outside the document_root.

you need to parse $r->filename.  File::Spec and the other File:: tools on
CPAN are your friend.

HTH

--Geoff