2017-05-24 9 views
-1

소유하고있는 코드는 정상적으로 작동하지만 다른 함수와 결합하면이 오류 메시지가 표시됩니다. "Tk :: Error : Can not use open_gui.pl 행 231에서 HASH 참조로 정의되지 않은 값. ". 231 행은 다음과 같습니다. "my $ output -> {$ count} = unpack ('C', getc ($ otp));" 아래는 내 코드입니다Tk :: Error : 해시 값으로 정의되지 않은 값을 사용할 수 없습니다.

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 입력으로부터 파일을 가져 오려고 할 때 오류를 표시합니다. 어느 누구도이를 도울 수 있습니까? 감사합니다

+1

https://eval.in/803952 =>'경고 사용;은 요일을 저장합니다. –

+0

사이드 노트, https://stackoverflow.com/a/8129070/223226 –

답변

0

해시 키를 선언 할 필요가 없습니다. 이 줄에서 "my"를 삭제하십시오.