ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-win32-web
perl-win32-web
Re: Perl/Binmode issue
by John Mason Jr other posts by this author
Jan 6 2007 1:12PM messages near this date
view in the new Beta List Site
Re: Perl/Binmode issue | ASP/PerlScript Issue - Please help
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/pdf\n";
>  print "Content-Disposition:attachment;filename=test3.pdf\n\n";
>  
>  my $files_location;
>  my $ID;
>  my @fileholder;
>  
>  $files_location = "C:\Data\Perl";
>  
>  open(DLFILE, "<$files_location\test.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
>  zahir@[...].net <mailto:zahir@[...].net>
>   
>  



Try letting perl tell you  when there is a problem

open(DLFILE, "<$files_location\test.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-Web@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
Zahir Lalani
$Bill Luebkert
Zahir Lalani
John Mason Jr

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved