您的位置:首页 > 其它

Perl Error and Exception Collections

2015-10-13 16:02 471 查看
1.Not a CODE reference

Perl试图将一个引用计算成一个代码值(也就是一个子例程),但是找到了指向其他东西的引用。你可以用ref函数看它究竟是什么类型的引用

print ref($var)

我遇到的情况主要是 UI grid 定位: 应该是 $entry_5->grid(-row => 5, -column => 2,-columnspan => 1);

而我把 “grid ” 漏掉了, 写成了 $entry_5->(-row => 5, -column => 2,-columnspan => 1);

2. hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at test1.pl line 19

用 perl hash 结构创建一个 json utf8字符串, 需要加引用\ , 如: encode_json \ %hash; 如果没有引用“\” ,就会报这个错

encode_json 函数等同于 to_json , to_json 也是需要有\ 的

3. garbage after JSON object, at character offset 77(...

4. , or } expected while parsing object/hash

5. cannot localize lexical variable $x ...

Referring : http://www.4byte.cn/question/350961/why-can-t-localize-lexical-variable-in-perl.html
6 . cannot find YAML on Ubuntu

sudo apt-get install libperl-dev

sudo
apt-get install libconfig-yaml-perl

7. TK::Error: Cannot decode string with wide characters at c:\Dwimperl\perl\lib/Encode.pm

错误抛出在我从 TK GUI 界面entry 中获得输入,拼接字符串。主要原因是TK entry 输入会自动decode 为Unicode, 而输出需要为 UTF8 , 如果两种字符串在一起混合就会报错。 需要把输入编码为utf8 , encode("utf8".$var) 再与其他字符串变量连接

croak
croak just like die , but die only show error line and position; croak show error line and position and process  name , see: http://blog.sina.com.cn/s/blog_8711d35c0100wuqc.html  http://stackoverflow.com/questions/24959739/or-expected-while-parsing-object-hash-error-while-parsing-a-json-file[/code] 
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: