in reply to Confused.... question on code scalability (reusing functions, etc)

Going back to your original question, you can (and probably should) build your SQL statements up from function params.

Here's an idea as to how that might be done with some untested code.

sub build_sql () { my $table = shift; my %where = @_; # should use hash refs, but this is an example my $sql = "select * from $table where "; foreach (keys(%where)) { #assumes quote() defined elsewhere to escape values $sql .= "$_ = ".quote($where{$_}).','; } chop $sql; #remove trailing comma return $sql }
Of course there are serveral modules on CPAN that can abstract you even further (and do so more robustly) from the SQL. Things like DBI::Abstract, Alzabo(sp?), etc.
  • Comment on Re: Confused.... question on code scalability (reusing functions, etc)
  • Download Code