in reply to Confused.... question on code scalability (reusing functions, etc)
Here's an idea as to how that might be done with some untested code.
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.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 }
|
---|