khizar wrote:
>
> hi guys
> i am trying to read a file <FILEHANDLE>
> before this i use the foll code
> if (-B $filepath) {binmode FILEHANDLE;}
>
> while (<FILEHANDLE>)
> {
> rest of stuff;
> }
> this code works fine for all files EXCEPT PDF files where it fails to
> detect the PDF file as binary file and hence binmode (FILEHANDLE) is not
> executed
>
> #########################################
> # read from the file into a stream
> # $stream = readf($filepath)
> #########################################
> sub readf {
> my ($path) = @_;
>
> open (FILEHANDLE,"$path") ;
> if (-B $path) { binmode (FILEHANDLE);}
Well, you can always try:
if (-B $file or $path =~ /pdf$/i) { ...
>
> $stream="";
>
> while ($line = <FILEHANDLE>)
> {
> $stream= $stream.$line;
> }
>
> close FILEHANDLE;
> return $stream;
> }
>
> $path = 'd:\test\a.pdf';
> $stream = readf($path);
> $l = length($stream);
--
,-/- __ _ _ $Bill Luebkert ICQ=14439852
(_/ / ) // // DBE Collectibles http://www.wgn.net/~dbe/
/ ) /--< o // // Mailto:[EMAIL PROTECTED] http://dbecoll.webjump.com/
-/-' /___/_<_</_</_ http://www.freeyellow.com/members/dbecoll/
---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
[EMAIL PROTECTED]
For non-automated Mailing List support, send email to
[EMAIL PROTECTED]