You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by ben syverson <be...@elsif.org> on 2005/02/12 09:37:11 UTC

[mp2] slurping files

What's the best way to slurp a file in mod_perl 2? I'm trying to use:
$r->filename('somefile.txt');
$text = ${ $r->slurp_filename() };

But it returns:
Error: read 23 bytes, expected 512 ('(null)')

The file is 23 bytes -- is mod_perl expecting files to end in a null 
char?

- ben


Re: [mp2] slurping files

Posted by ben syverson <be...@elsif.org>.
On Feb 12, 2005, at 10:52 AM, Stas Bekman wrote:

> Ben, the answer is here:
> http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_filename_

Ah -- I see! Thanks Stas,

- ben


Re: [mp2] slurping files

Posted by Stas Bekman <st...@stason.org>.
ben syverson wrote:
> What's the best way to slurp a file in mod_perl 2? I'm trying to use:
> $r->filename('somefile.txt');
> $text = ${ $r->slurp_filename() };
> 
> But it returns:
> Error: read 23 bytes, expected 512 ('(null)')
> 
> The file is 23 bytes -- is mod_perl expecting files to end in a null char?

Ben, the answer is here:
http://perl.apache.org/docs/2.0/api/Apache/RequestRec.html#C_filename_

I'll add a xref to this item from slurp_filename docs.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com