> > A few days ago, someone mentioned doing
> > $scalar = <STDIN>
> > read the whole POSTed data.

> The angle operator is subject to the $/ variable's current setting, per
> perlvar(1) and perlop(1).  Only when that variable's value is undef do
> you get the whole remainder of the input handle available as a single
> scalar value.
> [...]
> % man perlfaq5
>       How can I read in an entire file all at once?
> [...]
> --tom

perlvar, perlop and perlfaq5 are irrelevant here since the <FILE>
operator is overriden for STDIN under mod_perl if not using SFIO (and
maybe even if using SFIO). STDIN is tied to Apache::, as observed in
this snippet from perlio.c:
    void perl_stdin2client(request_rec *r)
    {
    #ifdef USE_SFIO
        sfdisc(PerlIO_stdin(), SF_POPDISC);
        sfdisc(PerlIO_stdin(), sfdcnewapache(r));
        sfsetbuf(PerlIO_stdin(), NULL, 0);
    #else
        if(TIED("STDIN")) return; 
        MP_TRACE_g(fprintf(stderr, "tie *STDIN => Apache\n"));
        TIEHANDLE("STDIN", perl_bless_request_rec(r));
    #endif
    }

It's up to the tied object's READLINE method to handle $/, but as seen
in this snippet from Apache.pm, $/ is completely ignored:
    #shouldn't use <STDIN> anyhow, but we'll be nice
    sub READLINE { 
    my $r = shift;
    my $line; 
    $r->read($line, $r->header_in('Content-length'));
    $line;
    }

Therefore, $scalar=<STDIN> returns the whole POSTed content (under
mod_perl and SFIO).

For more info on tied objects, refer to perltie.

Note: I didn't check when perl_stdin2client() is called or what
perl_bless_request_rec() returns. If my assumptions are wrong, then my
conclusion is too. Feel free to assert my assumptions by trying out
$scalar=<STDIN>; I would if I had mod_perl.

ELB

--
Eric L. Brine  |  Chicken: The egg's way of making more eggs.
[EMAIL PROTECTED]  |  Do you always hit the nail on the thumb?
ICQ# 4629314   |  An optimist thinks thorn bushes have roses.

Reply via email to