Any Perl victims care to explain this?

Anthony Wesley awesley at
Fri Apr 5 11:24:46 EST 2002

Matthew Hawkins wrote:
> I've been tearing what's left of my hair out for two days trying to deal
> with a simple problem.
> Any sane programmer would like to enjoy such wonderful programming
> constructs as obtaining the value of a key in a hash table (okay, a hash
> table reference), like so:
> $value = $table->{'key'};
> But thanks to Perl, which enjoys the full power of TIMTOWTDI, one must
> instead do:
> if (ref($table->{'key'}) eq "SCALAR") {
>         $value = ${$table->{'key'}};
> } elseif (ref($table->{'key'}) eq "ARRAYREF") {
>         $value = join(' ', @{$table->{'key'}});
> } else {
>         $value = [$table->{'key'}];
> }
> and pray to God that you don't encounter yet another random return type
> and have to add yet another conditional clause to deal with it.  Each
> time you need to use it.
> Why?  TIMTOWDI - there is more than one way to do it, and by God we're
> going to force you to use as many of them as possible.

The wonders of GIGO :-)

Usually I just do something like $sth->fetchrow_arrayref or
$sth->fetchrow_hashref and it Does What I Want.

Would you care to share the DBI interface part of your code with us, so
that we may point and giggle? :-)

cheers, Anthony

More information about the linux mailing list