[Dub-pm] hello

Aidan Kehoe kehoea at parhasard.net
Fri Jul 23 14:15:55 CDT 2004


 Ar an tríú lá is fiche de mí Iúil, scríobh Dave O Connor: 

 > Ta very much. Feel free to mail the list with any questions you come up with.
 > God knows it's quiet enough, we need any traffic we can get :)

Okay, here's something; 

    use DBI; 
    
    [... set up a connection, store the handle in $dbh ...]
    
    my $good_row_id = 12345;
    
    my $sh = $dbh->prepare_cached('SELECT fieldname FROM tablename WHERE
    row_identifier = ? ');
    
    my $certain_value = $sbh->selectall_arrayref->($sh, # [1]
       undef, $good_row_id);
    if (defined $certain_value && defined $certain_value->[0]->[0]) {
        $certain_value = $certain_value->[0]->[0];
    } else {
        $certain_value = 'default value';
    }
    
Why did line [1] even compile? What does it mean, given that it did? "Call
the result of selectall_arrayref with no arguments, and pass $sh, undef, and
$good_row_id as _its_ argument list?" Selectall_arrayref returns a reference
to an array, which, Jesus, should refuse to be called as a function. We're
not assembler. Nor even buffer-overflow-inclined C.

But, even more mad, looking back over the four months that major brain fart
was running code, how in God's name did it sometimes Do The Right Thing? 
Because it did; looking back through the records for those four months,
there's no other explanation for them than that it did--$certain_value ended
up as the right, non 'default value' string perhaps one time in five that
the code ran. Was there random reading of values off some conceptual stack? 
Can I turn on something stronger than -W to catch this shit in the future?

Bye, 
	- Aidan
-- 
The cow, if it were a metaphysician, would argue: 'Everything in my own
desires and hopes and fears has reference to myself; hence by induction I
conclude that everything in the universe has reference to myself. This noisy
train, therefore, intends to do me either good or evil. I cannot suppose
that it intends to do me good, since it comes in such a terrifying form, and
therefore, as a prudent cow, I shall endeavour to escape from it.' (Russell)



More information about the Dublin-pm mailing list