esscars's Weg ist sicher der richtigere (allein weil er funktioniert) ...
Hab den Code nochmal ein wenig gekürzt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
##################################
sub send_file_to_browser {
##################################
my $dest = shift;
my $file;
local $_;
chomp $$dest;
$$dest =~ s/\\/\//g;
($file = (split /\//, $$dest)[-1]) =~ s/\s/_/g;
binmode STDOUT;
print "Content-Type: application/*\n";
print "Content-Disposition: inline; filename=\"$file\"\n\n";
open FILE, "< $$dest" or die("File $file couldn't be opened");
binmode FILE;
print while <FILE>;
close FILE or die("File $file couldn't be closed");
}