On 03/28/2017 04:46 PM, SSC_perl wrote:
I could use another set of eyes on this. Could someone please double
check these two sets of conditions and let me know if the first is equivalent
to the second? I believe they are, but I don’t want to take any chances.
# Both of these should be equivalent.
$out->{$field} =~ s/``/\r/g unless (not $out->{$field} or $field eq
'categories');
$out->{$field} =~ s/``/\r/g if (defined $out->{$field} && $field ne
'categories');
google for demorgan's theorem. you should know it if you deal with
complex boolean logic.
the only difference i see is using defined in the 2nd line.
also i would test $field ne 'categories' first as if that is true why
even test $out->{$field}? it is a slight optimization but may also
clarify the logic.
$out->{$field} =~ s/``/\r/g if $field ne 'categories' && $out->{$field}
;
no need for the () on statement modifiers so i removed them. i also didn't use
defined as any value other than 0, '' or undef will be true and worth running
the s///.
uri
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/