in reply to collect all numeric form params and update database

Here you go:
# assuming $cgi = new CGI; # prepare update query my $sth = $dbh->prepare(' update pic_table set pic_value=? where pic_i +d=? '); # loop over all param names, and # grep out all those that are numerical foreach my $p( grep /^\d+$/, $cgi->param) { # find the form value my $v = $cgi->param( $p ); # execute the query $sth->execute( $v, $p ); }

Replies are listed 'Best First'.
Re^2: collect all numeric form params and update database
by Anonymous Monk on Mar 06, 2006 at 01:32 UTC
    That's actually very neat, however I am not using OOP on this. How would this be done without using CGI as an object?
      In that case, you can simply omit the $cgi->:
      foreach my $p( grep /^\d+$/, param() ) { # find the form value my $v = param( $p ); # execute the query $sth->execute( $v, $p ); }
      Note that DBI still uses OOP :)