Updating lots of database fields in a single row
William Blunn
bill+london.pm at blunn.org
Wed Jan 23 09:57:13 GMT 2013
On 23/01/2013 09:40, Ruud H.G. van Tol wrote:
> On 2013-01-23 10:27, William Blunn wrote:
>
>> my @fields_to_update = grep { $hash->{$_} } @fields;
>
> Be aware that it skips any false value, like undef, '', '0', 0.
Absolutely.
I wouldn't usually do a straight truth test on a scalar value myself,
unless the preceding code logic meant that it contained a boolean value.
I only coded it this way to match that part of the original semantics.
I think the OP would be well advised to consider using a more explicit
test such as:
exists $hash->{$_}
Regards,
Bill
More information about the london.pm
mailing list