大佬教程收集整理的这篇文章主要介绍了perl – ‘全局符号需要显式包名’的说明,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
该
#!/usr/bin/perl -w use Strict; sub croak { die "$0: @_: $!\n"; } sub output { my %chains = shift; my @keys = keys %chains; my $index = rand($keys); my $key = $keys[$index]; my $ouT_Buf = $key; for (my $i = 0; $i < 100; ++$i) { my $aref = $chains{$key}; my $word = @$aref[rand($aref)]; $ouT_Buf .= " $word"; $key =~ s/.+ //; $key .= " $word"; } print $ouT_Buf,"\n"; } sub get_chains { my %chains; my @prefixes while (my $line = <FILE>) { my @words = split " ",$line; foreach my $word (@words) { if ($prefixes == 2) { my $key = join " ",@prefixes; my $arr_ref = $chains{$key}; push(@$arr_ref,$word); shift @prefixes; } push(@prefixes,$word); } } return %chains; } sub load_book { my $path_name = shift @ARGV; open(FILE,$path_Name) || croak "File not found.\n"; } load_book; my %chains = get_chains; output %chains; ----ERRORS---- "my" variable $line masks earlier declaration in same statement at markov.pl line 33. "my" variable $path_name masks earlier declaration in same scope at markov.pl line 55. Global symbol "$keys" requires explicit package name at markov.pl line 12. syntax error at markov.pl line 32,near ") {" Global symbol "$prefixes" requires explicit package name at markov.pl line 36. Global symbol "%chains" requires explicit package name at markov.pl line 48. syntax error at markov.pl line 49,near "}" syntax error at markov.pl line 56,near "}" Execution of markov.pl aborted due to compilation errors.
我犯了什么错误?
以上是大佬教程为你收集整理的perl – ‘全局符号需要显式包名’的说明全部内容,希望文章能够帮你解决perl – ‘全局符号需要显式包名’的说明所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。