in reply to Re^2: Weird DBI behaviour
in thread Weird DBI behaviour

> I'm really perplexed that people find these names so confusing

$tbl_ary_ref = $sth->fetchall_arrayref; $tbl_ary_ref = $sth->fetchall_arrayref($slice); $tbl_ary_ref = $sth->fetchall_arrayref($slice, $max_rows); $tbl_ary_ref = $sth->fetchall_arrayref({foo=>1, BAR=>1}); $tbl_ary_ref = $sth->fetchall_arrayref({}); # They all are named the same but do things # differently. Which is strange, because Perl # makes a big deal (rightfully so, in my view) # that different things should look different. # # The last two are particularly perplexing (to me). # they don't even have the word 'hash' yet fetch # every row as a hash ref! # # That said, I use the last one all the time # because I can pass the returned data structure # directly to my beloved [cpan://HTML::Template] object.

Otoh, it could be just me. After a few years at Perl, I still can't tell the various punctuation variables apart (other than $_ and @_). It is funny, last week a friend went for an interview for a Perl job -- they had a quiz for him, and asked if what $& stood for. I would have failed the quiz immediately! Yet, I can program to save my life.

--

when small people start casting long shadows, it is time to go to bed

Replies are listed 'Best First'.
Re^4: Weird DBI behaviour
by jZed (Prior) on Aug 19, 2005 at 16:47 UTC
    # They all are named the same but do things # differently. Which is strange, because Perl # makes a big deal (rightfully so, in my view) # that different things should look different. #
    The methods are all named the same because they all do one thing: return results into a reference to an array. The arguements to the methods are different because they specify the nature or contents of that arrayref. Most methods behave diffently when passed different parameters.

    BTW, I'm not at all blaming you for being confused and I don't deny that it gets a bit mucky in there. I'm just pointing out that there is a more general logic to how DBI methods (and especially attributes to those methods) work.