ajkessel has asked for the wisdom of the Perl Monks concerning the following question:
It's the "pop" step right after the foreach loop that always seems wrong. If I don't do that "pop," there will be an extra "OR" hanging off at the end. It just seems ugly, though, to be pushing something onto an array just to pop it off after the last iteration. It strikes me as such a common situation that there must be a more elegant construct. What am I missing?foreach (@ARRAY) { push @WHERE, { X => $_ }, "OR"; } pop @WHERE; $DB->update( { table => 'table', fields => { Y => 0 }, where => \@where } );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Elegant way to turn array of values into SQL "where" clause
by jasonk (Parson) on Jul 03, 2006 at 00:16 UTC | |
|
Re: Elegant way to turn array of values into SQL "where" clause
by graff (Chancellor) on Jul 02, 2006 at 23:34 UTC | |
|
Re: Elegant way to turn array of values into SQL "where" clause
by GrandFather (Saint) on Jul 02, 2006 at 22:37 UTC | |
|
Re: Elegant way to turn array of values into SQL "where" clause
by Hue-Bond (Priest) on Jul 02, 2006 at 22:41 UTC |