for my $cd (@cds) { print $cd->name, $/; printf " - %d: %s\n", $_->num, $_->song->name for sort { $a->num <=> $b->num } $cd->tracks; } #### my $select = sprintf "select %s from $table where %s", join("," => @cols), join(" and " => map { "$_=?" } keys %constraints); my $sth = $dbh->prepare($select); $sth->execute( values %constraints ); ######### my $insert = sprintf "insert into $table (%s) values (%s)", join("," => keys %data), join("," => ('?') x scalar keys %data); my $sth = $dbh->prepare($insert); $sth->execute( values %data ); ########## my $update = sprintf "update $table set %s where %s", join("," => map { "$_=?" } keys %data), join(" and " => map { "$_=?" } keys %constraints); my $sth = $dbh->prepare($update); $sth->execute( values %data, values %constraints );