Eric Cholet wrote:
>
> > Hi all,
> >
> > I am using $r->path_info in an Apache handler. The handler is set via a
> > Location directive:
> >
> > <Location /cgi-bin/detail.pl> # Overcoming Legacy code :-)
> > SetHandler perl-script
> > PerlHandler eLogix::Images::Detail
> > </Location>
> >
> > And is called like "/cgi-bin/detail.pl/A1234567.jpg". My question is
> > this: Since there is no physical filename which corresponds to the URL,
> > what does path_info contain? In the eagle book on page 135, when
> > path_info is first discussed, the example uses
> > $r->lookup_uri($path_info) to get the filename, which in this example is
> > a purely virtual tree.
>
> $r->path_info contains what's left of the URI after it's been mapped
> to a (virtual) file, in your case /A1234567.jpg
>
> > I currently am using
> >
> > my $filename = (split /\//, $r->path_info)[1];
>
> or you could have used
> (my $filename = $r->path_info) =~ s!^/!!;
I had not considered doing it in one pass. :-) At the risk of exposing
my newbieness, where is this form documented? (I'll admit now to not
having read the Camel book cover to cover.)
> Since you have no trailing slash in your <Location> directive,
> you get a leading / in path_info. What would be the filename if the
> request URI was /cgi-bin/detail.pl/foo/bar.jpg ? In that case
> path_info will be '/foo/bar.jpg'. Maybe what you really want
> is
> my $filename = (split /\//, $r->path_info)[-1];
Another excellent point!
So if I put a trailing / in my <Location> directive, I won't get the
leading / and path_info will be just the information I need? That's what
I really wanted, and it's a simple solution as well. Thanks! :-)
--
Drew Taylor
Vialogix Communications, Inc.
501 N. College Street
Charlotte, NC 28202
704 370 0550
http://www.vialogix.com/