【发布时间】:2015-12-27 08:32:40
【问题描述】:
您好,我正在尝试编译 perl 程序,但它给出了错误。
这是我的代码
#!/usr/bin/perl
require './filemin-lib.pl';
use lib './lib';
use File::Basename;
use List::Util qw( min max );
use Cwd 'abs_path';
&ReadParse();
get_paths();
my $file = $cwd.'/'.$in{'file'};
my $size = -s "$file";
my $begin=0;
my $end=$size;
(my $name, my $dir, my $ext) = fileparse($file, qr/\.[^.]*/);
open (FILE, "< $file") or die "can't open $file: $!";
binmode FILE;
print "Content-Type: application/x-vlc-plugin\n";
print "Cache-Control: public, must-revalidate, max-age=0";
print "Pragma: no-cache" ;
print "Content-Disposition: attachment; filename=\"$name$ext\"\n";
print "Content-Transfer-Encoding: binary";
print "Accept-Ranges: bytes";
print "Content-Length: $end - $begin \n\n";
print "Connection: close";
#open (FILE, "< $file") or die "can't open $file: $!";
#binmode FILE;
my $cur=$begin;
seek(FILE,$begin,0);
while(!eof(FILE) && $cur < $end)
{
read FILE, min(1024*16) , $end-$cur;
$cur+=1024*16;
}
close FILE;
在我试图在vlc-plugin 的帮助下播放视频并且我正在尝试播放视频文件。但我没有找到我出错的地方。但是为此我遇到了错误
Can't modify non-lvalue subroutine call in read at download.cgi line 39, near "$cur;"
请有人帮帮我。在此先感谢。
【问题讨论】:
-
use strict;use warnings;在脚本开头是非常可取的。 -
阅读文档:
read( FILEHANDLE, SCALAR, LENGTH ) "attempts to read LENGTH characters into variable SCALAR。你应该正确地提供参数:给一个标量来存储,然后一个长度作为参数。他不能存储到min(1024*16)(不是左值) -
另外,我确定 for 循环实际上在做什么。也许对您总体上尝试做的事情发表评论会有所帮助。
-
我正在尝试借助插件播放视频..我无法打开文件
-
你开启严格和警告了吗?例如,我看不到 %in 被声明。因此,$in{file} 可能没什么用处。
标签: perl