Hi Marc,

On Sat, 19 May 2012 20:09:00 -0700
sono...@fannullone.us wrote:

>       I'm trying the following code from Programming Perl, but I'm get the 
> error "Can't call method "type" on unblessed reference at untitled text 10 
> line 23".  I've checked the errata page, but there's nothing listed for it.  
> Searching on the error message brings up pages about unblessed references, 
> but I can't make heads or tails out of them.  Does anyone know what the 
> problem is?
> 
> Thanks,
> Marc
> 
> 
> use v5.14;
> use strict;
> use warnings;
> 
> package Stables 1.01 {
>     use Moose;
>     has "animals" => (
>         traits  => ["Array"],
>         is      => "rw",
>         isa     => "ArrayRef[Animal]",
>         default => sub { [] },
>         handles => {
>             add_animal  => "push",
>             add_animals => "push",
>         },
>     );
>     sub roll_call {
>         my($self) = @_;
>         for my $animal($self->animals) {

The problem is that «$self->animals» returns an (unblessed) array reference and
not the list of individual animals, so you should do something like:

for my $animal (@{ $self->animals }) {

Note that I think I saw a way to return the flattened array in Moose, but I 
don't remember the specifics.

Regards,

        Shlomi Fish

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
What does "Zionism" mean? - http://shlom.in/def-zionism

Chuck Norris read the entire English Wikipedia in 24 hours. Twice.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to