Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hi Monks,

I'm trying to read a variable, that was set on the apache2 conf with PerSetVar, on a PerlPostReadRequestHandler, but so far all my tries failed.
I do see the variable when accessing it from the requested page.

A snipet of the post read request handler code:
... sub handler { my $r = shift; my $var = $r->dir_config('var'); $ENV{'VAR'} = $var; $ENV{'AM_I_SET'} = 'Yes'; return Apache2::Const::OK; }
When printing the %ENV I see AM_I_SET as 'Yes' but VAR is undef.

On the requested page I have:
my $r = shift; # template initialization not shown my $var = $r->dir_config('var'); $vars{'message'} = "Var is: $var"; $vars{'message'} .= '<br />'.Dumper(\%ENV); $template->process("hello.html", \%vars) || die $template->error();
The resulting web page will correctly display the value of 'var' and undef on %ENV.

I've been browsing the mod_perl2 docs, the Practical mod_perl book and searching the monastery and the web, but still haven't found the solution.

So, is it possible to access variables set with PerlSetVar from within the early handlers (those other than the final script)? How? What am I not doing?


In reply to PerlSetVar and PerlPostReadRequestHandler by olus

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (3)
    As of 2020-12-05 15:28 GMT
    Find Nodes?
      Voting Booth?
      How often do you use taint mode?

      Results (64 votes). Check out past polls.