> 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!^/!!;
> but it seems like such a hack. What is the "suggested" way to get the
> "A1234567.jpg" part of the above URL?
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];
whatever... it's completely up to the application to define the
semantics of path_info.
> --
> Drew Taylor
--
Eric