CGI-Application-Plugin-Stream
view release on metacpan or search on metacpan
lib/CGI/Application/Plugin/Stream.pm view on Meta::CPAN
111213141516171819202122232425262728293031@ISA
=
qw(Exporter)
;
@EXPORT_OK
=
qw(stream_file)
;
our
$VERSION
=
'2.12'
;
sub
stream_file {
my
(
$self
,
$file_or_fh
,
$bytes
) =
@_
;
$bytes
||= 1024;
my
(
$fh
,
$basename
);
my
$size
= (
stat
(
$file_or_fh
))[7];
# If we have a file path
if
(
ref
( \
$file_or_fh
) eq
'SCALAR'
) {
# They passed along a scalar, pointing to the path of the file
# So we need to open the file
open
(
$fh
,
"<$file_or_fh"
) ||
return
0;
# Now let's go binmode (Thanks, William!)
binmode
$fh
;
$basename
= basename(
$file_or_fh
);
}
( run in 0.289 second using v1.01-cache-2.11-cpan-2b0bae70ee8 )