#!/usr/bin/perl --
use strict;
print "Content-type: application/octet-stream\n";
print "Content-disposition: attachment; filename=big-test.csv\n\n";
print "Test,One,Two,Three\n";
exit;
####
my $app = sub {
return
[ ## response
[ ## headers
'Content-Disposition' => 'attachment; filename="$filename"',
'Content-length' => '3',
'Content-Type' => '$mimetype',
],
[ ## content
123
]
];
};
##
##
#!/usr/bin/perl --
use strict;
use warnings;
use CGI ( );
binmode STDOUT;
my $q = CGI->new;
print $q->header(
-type => $mimetype,
-attachment => $filename,
-Content_length => -s $filehandle,
);
...
##
##
#!/usr/bin/perl --
use strict;
use warnings;
use CGI qw( param header );
binmode STDOUT;
print header(
-type => $mimetype,
-attachment => $filename,
-Content_length => -s $filehandle,
);
...