Geoffrey Young wrote

> I'm surprised that this works at all...  what's in @kv at this point?  if
> it's only two values then it might work if there is some magic behind the
> scenes, but generally you can't store references in PerlSetVars without
> having them stringified.  Maybe PerlAddVar would work for you, though...

I found an example that did this almost exactly the way I did... then lost
the URL to the example.  Anyway, replacing it with a string (so you only
ever get the last key-value pair in the file) works for defining the
variable (See new source appended).

> maybe something like Apache::Storage would help as well...

Looked at it, seemed too heavyweight for something that was just key=value.

> for general debugging see man Apache::PerlSections and the
> Apache::PerlSections->dump method.  There's also an entire section on
> debugging <Perl> sections in the Eagle book.

Don't have the Eagle book yet (buying it today).  The PerlSections->dump
looks right according to the documentation on Apache::PerlSections - but I
still get the confused multiple loading problem - it's like a bunch of the
locations are all matching to the one location that generates mutliple
sub-frames.

Ok, the problem seemed to be that I had a bunch of keys '/areaj-foo' and one
key '/areaj' - and somehow, the Location match on just '/areaj' was
capturing all of them.  I had a hunch and changed the key to 'areaj-areaj'
so that there wouldn't be any spurious matches, and it worked!

This *is* a bug, right?  Location is supposed to be an exact match, isn't
it?

Geoff- thanks for the help.  It wasn't quite 'full-case-of-beer' help, but I
definitely owe you one.

//Thomas
Thomas K. Burkholder
[EMAIL PROTECTED]

The code:
  <perl>
    use IO::File;
    use Data::Dump;
    use Apache::PerlSections ();
    # convert this to per-user match later
    my $filename = "/home/burkhold/perl/PerlSetVar";
    my $file = IO::File->new("< $filename");
    my $str = '';
    if ($file) {
      my $ref;
      while (<$file>) {
        $ref=undef;
        s/(\w+)\s*=\s*(.*)\s*$/$str = "$1 $2"/e;
      }
      $file->close();
    }
    my $mapping = getMapping();
    my ($key, $value);
    while (($key, $value) = each(%$mapping)) {
      print "got $key = $value\n";

      my %loc = (
        PerlSetVar => $str,
        SetHandler => 'perl-script',
        PerlHandler => $value
      );
      $Location{$key} = \%loc;
    }

    print Apache::PerlSections->dump;

    sub getMapping {
      my $filename = "/home/burkhold/perl/mod_perl_mapping";
      my $file = IO::File->new("< $filename");
      my %result = ();
      if ($file) {
        while (<$file>) {
          my ($key, $value);
          s/(.*)\s*=\s*(.*)\s*$/($key, $value) = ($1,$2)/e;
          print "mapping $key to $value\n";
          $result{$key} = $value;
        }
        $file->close();
      }
      return \%result;
    }
  </perl>

The data:

/home/burkhold/perl/mod_perl_mapping:

/areaj-areaj=AreaJ::AreaJ
/areaj-genpage=AreaJ::GenPage
/areaj-search=AreaJ::Search
/areaj-genimg=AreaJ::GenImage
/areaj-genfooter=AreaJ::GenFooter
/areaj-login=AreaJ::Login
/areaj-genlogin=AreaJ::GenLogin
/areaj-logout=AreaJ::Logout
/areaj-gensearch=AreaJ::GenSearch
/areaj-modmany=AreaJ::ModMany
/areaj-getpage=AreaJ::GetPage
/areaj-mark=AreaJ::Mark
/areaj-genpasswd=AreaJ::GenPasswd
/areaj-passwd=AreaJ::Passwd
/areaj-genmanageuser=AreaJ::GenManageUser
/areaj-selandredir=AreaJ::SelectAndRedirect
/areaj-genusertagtree=AreaJ::GenUserTagTree
/areaj-edit=AreaJ::EditImage
/areaj-gendelete=AreaJ::GenDelete
/areaj-delete=AreaJ::Delete
/areaj-genupload=AreaJ::GenUpload
/areaj-upload=AreaJ::Upload
/areaj-ensure=AreaJ::Ensure
/areaj-genheader=AreaJ::GenHeader
/areaj-gennewuser=AreaJ::GenNewUser
/areaj-newuser=AreaJ::NewUser

/home/burkhold/perl/PerlSetVar:

areajpassword=areaj


Reply via email to