!/usr/bin/perl

$file="../form1/1001du.txt";
open(IN, $file) || die ("can't open file");
&slurpfile ($file);
@fields=split(/\012/, $text);
$newlines=join($/,@fields);
print "Content-type: text/html\n\n";
print $newlines;


print header( -type => 'application/x-download',
-attachment => $ID,
);

#print $_ while (read(DLFILE, $_, 1024));
#close (DLFILE) || die ("Can't close file!");

open(LOG, ">>/home/mortga20/public_html/$subdirectory/log.txt") || die ("Can't open file!");
print LOG "$ID\n";
close (LOG);

print "Content-Type:application/x-download\n";
print "Content-Disposition:attachment;filename=$ID\n\n";
print @fileholder;

sub slurpfile {

local( $/, *FH ) ;
open( FH, $file ) or die "unable to read file\n";
$text = <FH>;
}

I tried to get this to work, but to no avail. I'm not sure how to fake the headers to the browser so that it presents the file save as dialog. I'm trying to convert a text file on a unix server to remove the LF character and make it windows compatible. (remove the pesky squares seen in notepad) I open the file, slurp it in, do the split and join, and then I need to present that string in a file save as. Does this routine have to read from a file? Can it use the string I just made? I tried to split and join the file back using $/ as glue. Does anyone know how to make this work?