List Info

Thread: Perl/Binmode issue




Perl/Binmode issue
user name
2007-01-06 15:42:17
Hello
 
not sure what is going on here. I have a standard xampp install on win XP, with the updated install of perl - which is activeperl 5.8.8. I have some test code to send a pdf from the cgi to the browser as follows:
 

#!C:/Program Files/xampp/perl/bin/perl

print "Content-Type:application/pdfn";
print "Content-Disposition:attachment;filename=test3.pdfnn";

my $files_location;
my $ID;
my fileholder;

$files_location = "C:DataPerl";;

open(DLFILE, "<$files_locationtest.pdf");
binmode(DLFILE);
binmode(STDOUT);
fileholder = <DLFILE>;
close (DLFILE);

print fileholder;

====

When I run this, I get the save as dialog. Whether I save or open directly, the resulting data is deemed as corrupt by acrobat. If I access the file directly via apache rather than the cgi, it works fine. To make sure the code was OK, I ran the same code (apart from the paths and the binmode) on a unix install - and it worked fine. I also tried an equivalent version of PHP via the xampp install - worked fine. So this seems to be a perl issue on win32.

Has anyone got a clue as to what the problem could be?

&nbsp;

Thx


--
Zahir Lalani
SystemZ
zahirsystemz.net">zahirsystemz.net
 
Perl/Binmode issue
user name
2007-01-06 21:12:09
Zahir Lalani wrote:
> Hello
>  
> not sure what is going on here. I have a standard xampp
install on win
> XP, with the updated install of perl - which is
activeperl 5.8.8. I have
> some test code to send a pdf from the cgi to the
browser as follows:
>  
> 
> #!C:/Program Files/xampp/perl/bin/perl
> 
> print "Content-Type:application/pdfn";
> print
"Content-Disposition:attachment;filename=test3.pdfnn&
quot;;
> 
> my $files_location;
> my $ID;
> my fileholder;
> 
> $files_location = "C:DataPerl";
> 
> open(DLFILE, "<$files_locationtest.pdf");
> binmode(DLFILE);
> binmode(STDOUT);
> fileholder = <DLFILE>;
> close (DLFILE);
> 
> print fileholder;
> 
> ====
> 
> When I run this, I get the save as dialog. Whether I
save or open
> directly, the resulting data is deemed as corrupt by
acrobat. If I
> access the file directly via apache rather than the
cgi, it works fine.
> To make sure the code was OK, I ran the same code
(apart from the paths
> and the binmode) on a unix install - and it worked
fine. I also tried an
> equivalent version of PHP via the xampp install -
worked fine. So this
> seems to be a perl issue on win32.
> 
> Has anyone got a clue as to what the problem could be?
> 
>  
> 
> Thx
> 
> 
> -- 
> Zahir Lalani
> SystemZ
> zahirsystemz.net <mailto:zahirsystemz.net>
>  
> 



Try letting perl tell you  when there is a problem

open(DLFILE, "<$files_locationtest.pdf")||
die("can't open datafile: $!");

I would also put in

use warnings;
use strict;

and

use CGI::Carp;
die "Fatal error messages are now sent to
browser";


John




_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Weblistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
Perl/Binmode issue
user name
2007-01-07 00:19:47
Zahir Lalani wrote:
> Hello
>  
> not sure what is going on here. I have a standard xampp
install on win 
> XP, with the updated install of perl - which is
activeperl 5.8.8. I have 
> some test code to send a pdf from the cgi to the
browser as follows:
>  
> 
> #!C:/Program Files/xampp/perl/bin/perl
> 
> print "Content-Type:application/pdfn";
> print
"Content-Disposition:attachment;filename=test3.pdfnn&
quot;;
> 
> my $files_location;
> my $ID;
> my fileholder;
> 
> $files_location = "C:DataPerl";
> 
> open(DLFILE, "<$files_locationtest.pdf");
> binmode(DLFILE);
> binmode(STDOUT);
> fileholder = <DLFILE>;
> close (DLFILE);
> 
> print fileholder;
> 
> ====
> 
> When I run this, I get the save as dialog. Whether I
save or open 
> directly, the resulting data is deemed as corrupt by
acrobat. If I 
> access the file directly via apache rather than the
cgi, it works fine. 
> To make sure the code was OK, I ran the same code
(apart from the paths 
> and the binmode) on a unix install - and it worked
fine. I also tried an 
> equivalent version of PHP via the xampp install -
worked fine. So this 
> seems to be a perl issue on win32.
> 
> Has anyone got a clue as to what the problem could be?

The only thing obvious is your s should be \s when inside
double
quotes.  State your OS, webserver, browser so we have some
idea of
your environment and also do as previously suggested:

use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);

You could also try hex-dumping the file and the returned
file and
see what's different.
_______________________________________________
Perl-Win32-Web mailing list
Perl-Win32-Weblistserv.ActiveState.com
To unsubscribe: http:/
/listserv.ActiveState.com/mailman/mysubs
Perl/Binmode issue
user name
2007-01-07 16:38:15
Thanks to all who replied. problem solved.
 
 
Zahir

The only thing obvious is your s should be \s when inside double
quotes. &nbsp;State your OS, webserver, browser so we have some idea of
your environment and also do as previously suggested:

use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);

You could also try hex-dumping the file and the returned file and
see what's different.



--
Zahir Lalani
SystemZ
zahirsystemz.net">zahirsystemz.net
[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )