dos2unix perl/cgi script debug help
This script, posted earlier on this list, has one major problem: it
doesn't send the file! If "use strict;" is removed, it'll send the file,
but it is _larger_ than the original file... I'm thinking that it needs
some type of indicator that it is finished sending the file.. I'd really
appreciate any help
Thanks
-Paul
#!/usr/bin/perl
use strict;
use CGI;
##############################################################################
my $self=new CGI;
### our state is based on whether we have access to some variables
if (defined($self->param('xfile')) && defined($self->param('DIRECTION')))
{
my $file=$self->param('xfile');
my $tounix=($self->param('DIRECTION') eq 'DOS2UNIX');
my $short=$1 if $file=~/([_\-\d\.\w]+)$/;
$short||="unknown.txt";
print "Content-type: application/octet-stream\n";
print "Content-Disposition: inline; filename=$short\n\n";
while ($_=<$file>) {
chomp;
print;
if ($tounix) {
print "\n";
}
else {
print "\r\n";
};
};
};
exit;
Reply to: