
lannings at who
Jul 27, 2008, 2:07 PM
Post #5 of 8
(313 views)
Permalink
|
In Bricolage, Whatever->list ordinarily returns an array reference (which is a scalar) in scalar context, or a list in list context. In my $foo = ... it is a scalar context, so it will be an aref, and you'd access it like $foo->[0] or whatever. In my ($foo) = ... or my ($foo, $bar) = ... or my ($foo, undef, undef, $quux) = ... or my @foo = ... or even my %foo = ... it is a list context. (Assigning to a hash (%foo) would be stupid for Whatever->list, however.) In the case of my ($foo) = ... only the first item of the list will be put in $foo, while any more items will be discarded. $foo will generally be an object (instance) of Whatever class. If you use Whatever->list_ids in most classes, it will return a list of ID numbers instead of objects. On Fri, 25 Jul 2008, Trevor Smith wrote: > weird, yeah i get the same error from this line: > my $container = Bric::Biz::Element::Container->list({object => > $uidstory, key_name => 'event_uid'}); > > unless i do this: > my ($container) = Bric::Biz::Element::Container->list({object => > $uidstory, key_name => 'event_uid'}); > > On Fri, Jul 25, 2008 at 3:51 PM, Schults, Chris > <chris.schults[at]pccsea.com> wrote: >>> The new error that I keep getting is: >>> Can't call method "get_elements" on unblessed reference at >>> /usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event.mc line >>> 87, <GEN2441> line 1716. >>> >>> My question is what is an unblessed reference? I am getting the above >>> error on this line from above: "foreach my $euid >>> ($uidstory->get_elements()){". >> >> Trevor, I run into this all the time and embarrassingly don't exactly >> know the reason behind it. However, I believe it is because Story->list >> returns an array or list. I get around this by putting the variable >> declaration in parenthesis like so: >> >> my ($uidstory) = Bric::Biz::Asset::Business::Story->list({uuid => >> '595FC2AC-58B9-11DD-800B-39D208E6C7E9'}); >> >> Perhaps the more experienced can enlighten us. >> >> Chris
|