[cgiapp] Re: How to send pdf file?

petr.vojkovsky at centrum.cz petr.vojkovsky at centrum.cz
Tue Feb 5 14:08:12 EST 2008


Thank you very much, guys.
It works!

Best regards,
Petr
______________________________________________________________
> Od: pagaltzis at gmx.de
> Komu: cgiapp at lists.openlib.org
> Datum: 03.02.2008 20:26
> Předmět: [cgiapp] Re: How to send pdf file?
>
>* petr.vojkovsky at centrum.cz <petr.vojkovsky at centrum.cz> [2008-02-03
11:55]:
>> @fileholder = <FILE>;  
>> print @fileholder;
>
>* Jesse Erlbaum <jesse at erlbaum.net> [2008-02-03 14:50]:
>>    @fileholder = <FILE>;
>>    return join("", @fileholder);
>
>Note that this is a really bad way to slurp a whole file. In the
>worst case (2nd example) it will consume over thrice the size of
>the file in memory.
>
>In general, if you do slurp an entire file, you should do it
>using `read`:
>
>    read *FILE, $fileholder, -s *FILE;
>
>But if you do that and then `return $fileholder`, you´ll still
>get double the size of the file in memory consumption, because
>Perl makes a copy of the scalar to return it.
>
>The right approach in such cases is either passing around a file
>handle (so the output can be streamed directly) or a reference
>(but then the code which outputs it must still be written
>carefully to avoid making a copy).
>
>In case of a CGI::App app, the answer is to pass a file handle,
>which is done using CGI::Application::Plugin::Stream. That will
>also conveniently take care of setting all the requisite headers.
>
>-- 
>*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined
wantarray]/e;$1}
>&Just->another->Perl->hack;
>#Aristotle Pagaltzis // <http://plasmasturm.org/>
>
>#####  CGI::Application community mailing list  ################
>##                                                            ##
>##  To unsubscribe, or change your message delivery options,  ##
>##  visit:  http://lists.openlib.org/mailman/listinfo/cgiapp    ##
>##                                                            ##
>##  Web archive:   http://lists.openlib.org/pipermail/cgiapp/   ##
>##  Wiki:          http://cgiapp.erlbaum.net/                 ##
>##                                                            ##
>################################################################
>
>



More information about the cgiapp mailing list