On Mon, 29 Jan 2001, you wrote:

> > Sounds like your dereferencing function may be returning a SCALAR instead
> > of an ARRAY when there's only one result?
> 
> could be ... I had :
> 
> my($data)=$sth->fetchall_arrayref;
> return @{$data};
> 
> which I thought should return a flat list of references to arrays ... ??
> nope?

so .. after a quick fiddle .. 

It seem T::T automagically assumes that if you pass it a reference to
something then you probably didn;t want that, you prolly wanted the thingy
itself so it dereferences it for you.. it will only do this down one
level.

so by passing it a list of references it sees a list .. does a foreach
down them and then sees what it gets (in this case an array ref ) .. it
dereferences that and bingo you can now access the row of stuff.

however when the list jsut contains 1 item, it sees a reference to an
array ( whicj is the row) and then proceeds to do a foreach over the
elements of the row ..

by simply not passing it the thing in list format  but passing the plain
reference (ie return $data instead of @{$data}) it always gets an arrayref
and works for both cases of 1 or n items in the array.

solved .. it just took me a while to twig what was going on.

-- 
Robin Szemeti

The box said "requires windows 95 or better"
So I installed Linux!

Reply via email to