taint has asked for the wisdom of the Perl Monks concerning the following question:

Greetings, I thought I'd take a look at CPAN-Forum. I downloaded the module/package, inspected, then installed the dependencies, and finally built, tested, and installed it. Everything went as expected. However, I seem to be having troubles with hosting it in a sub-directory within the web site's document root "/". While it does attempt to set the (it's) DOCROOT (ROOT) when it initializes, it doesn't appear to stick. Anyway, The following error might have something to do with it:
Use of uninitialized value $ENV{"PATH_INFO"} in pattern match (m//) at + Forum.pm line 674
The line in question (with fuller context):
if (not $rm or $rm eq "home") { if ($ENV{PATH_INFO} =~m{^/ # Line 674 ([^/]+) # first word till after the first / (?:/(.*))? # the rest, after the (optional) second / }x) { my $newrm = $1; my $params = $2 || ""; if (grep {$newrm eq $_} @urls) { my @params = split /\//, $params; $self->param(path_parameters => @params ? \@params : []); $rm = $newrm; $self->prerun_mode($rm); } elsif ($ENV{PATH_INFO} eq "/cgi/index.pl") { # TODO this is temporary to avoid unnecessary warnings } else { warn "Invalid PATH_INFO: $ENV{PATH_INFO}"; # shall I make more noise ? } } }
While I could imagine picking an unlikely to be used name, and declare/assign it to ($ENV{PATH_INFO}...) It seems that that environment variable should already exist -- I haven't had trouble(s) in the past with it.

Any helpful suggestions, greatly appreciated.

Thank you for all your time, and consideration.

--chris

#!/usr/bin/perl -Tw
use perl::always;
my $perl_version = "5.12.5";
print $perl_version;

Replies are listed 'Best First'.
Re: CPAN-Forum -- problem with "Use of uninitialized value"
by taint (Chaplain) on Oct 01, 2013 at 23:04 UTC
    OK. Further reading seems to indicate this is a known issue.
    From: http://search.cpan.org/~szabgab/CPAN-Forum-0.11/lib/CPAN/Forum.pm#TODO...
    Shlomi: The Forum uses cgiapp_prerun to set the mode according to the PATH_INFO instead of using a mode_param code-reference. This causes a lot of warnings in the logs, and doesn't really belong in cgiapp_prerun.

    It cannot be hosted on a URL except for its own virtual host, as it uses absolute URLs. ("/login/", "/register/", etc.) A better idea would be to track the path that the web-server gives (it's in one of the environment variables) and then to construct a /cpan-forum/login/ /cpan-forum/register/ etc. path. (or use relative URLs).
    Anyone care to venture a solution, or avenue I could travel to allow this to live one level deeper that the web site's document root -- how I might "pin" cpan-forum ahead of the current links?

    Thank you for all your time, and consideration.

    --chris

    #!/usr/bin/perl -Tw
    use perl::always;
    my $perl_version = "5.12.5";
    print $perl_version;
      OK. Still trying to work this out...
      Would something like this:

      if ($self->query->url_param($self->mode_param)) {

      work?
      Yea, I know -- I don't know, did you try it?
      I would, but don't know how to introduce it properly.
      Sorry.

      Thank you for all your time, and consideration.

      --chris

      #!/usr/bin/perl -Tw
      use perl::always;
      my $perl_version = "5.12.5";
      print $perl_version;