曲径通幽论坛

标题: "Can't call method xxxx on unblessed reference at" 错误 [打印本页]

作者: beyes    时间: 2011-11-1 12:00
标题: "Can't call method xxxx on unblessed reference at"
当使用了一个非对象的引用来使用方法时,会提示 "Can't call method xxxx on unblessed reference at" 的错误,比如:
[code=perl]#!/usr/bin/perl


use strict;
use warnings;


my $ref = {
                a => "hello",
                b => "world",
};


$ref->print;
[/mw_shl_code]
运行输出:
$ ./temp.pl
Can't call method "print" on unblessed reference at ./temp.pl line 11.





欢迎光临 曲径通幽论坛 (http://www.groad.net/bbs/) Powered by Discuz! X3.2