> Just as a side note... this is really a stylistic or idiomatic argument.
<snip>
Precisely right. That once again is a bad example I guess :) It is just
dictated by the way all the rest of the error handling is done. For
example:
sub check_table {
my ($dbh, $table) = @_;
$table = lc $table;
my $tab_ref;
eval { my $tb_h = $dbh->table_info ();
$tab_ref = $tb_h->fetchall_arrayref ();
}
or do {
$ERROR = "Execution of DBI->table_info() failed:\n" . $dbh->errstr;
return undef;
};
unless (grep { ($_->[2] eq $table) and ($_->[3] eq 'TABLE') } @{$tab_ref} )
{
$ERROR = "Table '$table' does not exist";
return undef;
}
my $col_ref;
eval { my $cl_h = $dbh->column_info (undef, undef, $table, '%');
$col_ref = ($cl_h->fetchall_hashref ('COLUMN_NAME') );
}
or do {
$ERROR = "Execution of DBI->column_info() for '$table' failed:\n" .
$dbh->errstr;
return undef;
};
my @expected_columns = describe_table ($table);
if ( (keys %{$col_ref} != scalar @expected_columns)
or
(grep { ! defined $col_ref->{$_} } @expected_columns) ) {
$ERROR = "Layout of '$table' is invalid";
return undef;
}
return 1;
}
So the connect() subroutine which you saw in the previous mail simply
follows this model, although it is a different animal on the inside.
Peter
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>