【问题标题】:Tk::Error: Can't use an undefined value as HASHTk::Error: 不能使用未定义的值作为 HASH
【发布时间】:2017-05-24 06:35:51
【问题描述】:

我有自己可以正常工作的代码,但是当我与另一个函数结合使用时,它会显示此错误消息“Tk::Error: Can't use an undefined value as a HASH reference at open_gui.pl line 231。 ”。第 231 行是这一行“我的 $output->{$count} =unpack('C',getc($otp));”下面是我的代码

sub main($$){

    my $call_form = shift ;
    my $file1 = shift -> get() ;
    my $output={};
    bless $output;
    my $j =0;
    my $i =0;
    grab_file($output,$file1);
}

sub grab_file($$){

    my $output=shift;
    my $file = shift;
    open(my $otp, '<' , "$file") or die "Error, File1 could not open\n"; 
    open(my $input, "> info.txt") or die "Error, File3 could not open\n";
    my $count = 0;
    binmode($otp);
    seek ($otp,829440,0);
    for my $count (0..27648){
        my $output->{$count} =unpack('C',getc($otp));
        print $input "$output->{$count}\n";;
    }
    close ($input);
    close($otp);
    open(FILE4, ">data.txt") or die "Error, File4 could not open\n";
    open ( my $input, '<', "info.txt" ) or die $!;
    chomp ( my @file = <$input> ); 
    print FILE4 join (" ",splice (@file, 0, 16)),"\n"while @file;
    close($input);
    close(FILE4);

}

这是部分代码,这里没有显示的代码的上半部分主要是构建GUI的tk。这个没有与此处未显示的 Tk 函数结合的子例程可以通过自行将二进制文件名放入 $otp 来正常工作,但是当我想从 GUI 的输入中获取文件时,它会显示错误。任何人都可以为此提供帮助吗?谢谢

【问题讨论】:

标签: perl hash tk


【解决方案1】:

您不需要声明哈希键。从此行中删除“我的”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-16
    • 1970-01-01
    • 2011-07-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多