Home > Archive > PERL Beginners > July 2005 > What does "unblessed reference" mean?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
What does "unblessed reference" mean?
|
|
| Dave Adams 2005-07-26, 5:00 pm |
| I got this error that reads something like: Can't call method "print"
on unblessed reference at {script name} , <STDIN> chunk 1.
In general terms, can anyone tell the what this is about so I can comb
through my script and fix this problem.
Thanks in advance,
Dave Adams
| |
| Jan Eden 2005-07-26, 5:00 pm |
| Hi Dave,
Dave Adams wrote on 26.07.2005:
>I got this error that reads something like: Can't call method
>"print" on unblessed reference at {script name} , <STDIN> chunk 1.
>
>In general terms, can anyone tell the what this is about so I can
>comb through my script and fix this problem.
>
>Thanks in advance, Dave Adams
>
You probably did something like
$var->print
This only works if $var is a blessed reference, i.e. an object of a class c=
ontaining the subroutine (method) print.
Cheers,
Jan
--=20
There are two major products that come out of Berkeley: LSD and UNIX. We do=
n't believe this to be a coincidence. - Jeremy S. Anderson
| |
| John Doe 2005-07-26, 5:00 pm |
| Dave Adams am Dienstag, 26. Juli 2005 17.29:
> I got this error that reads something like: Can't call method "print"
> on unblessed reference at {script name} , <STDIN> chunk 1.
>
> In general terms, can anyone tell the what this is about so I can comb
> through my script and fix this problem.
This means that you tried to call a method of something that's not an object
(= blessed reference).
In the following example, the error is triggered because $href is just a
simple hash reference:
$ perl -le '
use strict; use warnings;
my $href={a => "b"};
$href->print;'
Can't call method "print" on unblessed reference at -e line 4.
In the next example, a blessed reference is used, but the method does not
exist:
perl -le '
use strict; use warnings;
my $href=bless {a => "b"}, "SomeClass";
$href->print;'
Can't locate object method "print" via package "SomeClass" at -e line 4.
If this does not help,
- provide code
- read some perl documentation, f.e.
perldoc perlobj
perldoc perlmod
- wait for answers of one of the list gurus
joe
|
|
|
|
|