davis has asked for the wisdom of the Perl Monks concerning the following question:
The five trailing braces just feel "wrong" to me, in particularmy $action = param("ACTION"); if($action) { #Bond the built-in and accessory components to the parent. if($action eq "BOND") { my $main = param("MAIN"); my @built = param("BUILT"); my @acc = param("ACC"); my $query = "SELECT location FROM demstock2 WHERE ds_i +d=$main"; my $sth = $db->prepare($query); $sth->execute or print "Can't execute <pre>$query</pre +>: " . $db->errstr . "<br>\n"; my $mainlocation = $sth->fetchrow_hashref; if($mainlocation->{"location"} ne "STOCK") { print b("Refusing to bond items to $main, as i +t isn't in main stock") . br(); } else { $sth->finish(); for my $acc (@acc) { my $query = "SELECT curr_parent_id FRO +M demstock2 WHERE ds_id=$acc"; my $sth = $db->prepare($query); $sth->execute() or print "Can't execut +e $query: " . $sth->errstr . "<br>\n"; my $current_status = $sth->fetchrow_ha +shref; $sth->finish(); if($current_status->{"curr_parent_id"} + != 0) { print "Refusing to modify the +status of demstock $acc. It has already been moved<br>\n"; } else { my $query = "UPDATE demstock2 +SET curr_parent_id=$main WHERE ds_id=$acc"; my $sth = $db->prepare($quer +y); $sth->execute or print "Can't +execute <pre>$query</pre>: " . $db->errstr . "<br>\n"; $sth->finish(); $query = "INSERT INTO action " +; $query .= "(action_id, actio +n_type, ds_id, occurred, ref_no, staff_id) VALUES" ; $query .= "(NULL, 'MOVE +', $acc, CURRENT_TIMESTAMP, \"0,$main\", $caluser)"; $sth = $db->prepare($query); $sth->execute or print "Can't +execute <pre>$query</pre>: " . $db->errstr . "<br>\n"; $sth->finish; } } for my $built (@built) { my $query = "SELECT curr_parent_id FRO +M demstock2 WHERE ds_id=$built"; my $sth = $db->prepare($query); $sth->execute() or print "Can't execut +e $query: " . $sth->errstr . "<br>\n"; my $current_status = $sth->fetchrow_ha +shref; $sth->finish(); if($current_status->{"curr_parent_id"} + != 0) { print "Refusing to modify the +status of demstock $built. It has already been moved<br>\n"; } else { my $query = "UPDATE demstock2 +SET curr_parent_id=$main WHERE ds_id=$built"; my $sth = $db->prepare($quer +y); $sth->execute() or print "Can' +t execute $query: " . $sth->errstr . "<br>\n"; $sth->finish(); $query = "INSERT INTO action " +; $query .= "(action_id, actio +n_type, ds_id, occurred, ref_no, staff_id) VALUES" ; $query .= "(NULL, 'MOVE +', $built, CURRENT_TIMESTAMP, \"0,$main\", $caluser)"; $sth = $db->prepare($query); $sth->execute or print "Can't +execute <pre>$query</pre>: " . $sth->errstr . "<br>\n"; $sth->finish; } } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A question of style.
by Masem (Monsignor) on Oct 30, 2001 at 19:41 UTC | |
by davis (Vicar) on Oct 30, 2001 at 21:15 UTC | |
by Masem (Monsignor) on Oct 30, 2001 at 21:48 UTC | |
by tommyw (Hermit) on Oct 30, 2001 at 21:26 UTC | |
|
On the indentation front
by Fletch (Bishop) on Oct 30, 2001 at 19:36 UTC | |
|
Re: A question of style.
by tommyw (Hermit) on Oct 30, 2001 at 19:51 UTC | |
|
Re (tilly) 1: A question of style.
by tilly (Archbishop) on Oct 30, 2001 at 22:23 UTC | |
by jlongino (Parson) on Oct 30, 2001 at 23:26 UTC |