Skip to content

mysqltuner.pl does not use standard Perl practice for Boolean scalars #34

Description

@lewart3

Perldata Scalar values:
    https://perldoc.perl.org/perldata#Scalar-values
says:

A scalar value is interpreted as FALSE in the Boolean sense if it is undefined, the null string or the number 0 (or its string equivalent, "0"), and TRUE if it is anything else.

mysqltuner.pl is littered with phrases like these:

  1. default => '0',
  2. if ( $var eq "" )
  3. if ( $var eq '' )
  4. if ( $var ne "" )
  5. if ( $var ne '' )
  6. if ( ( $var // '0' ) eq '0' )
  7. if ( ( $var // '0' ) ne '0' )
  8. if ( ( $var || "" ) eq "" )

To follow standard Perl practice, they should be simplified to:

  1. default => undef,
  2. if ( !$var )
  3. if ( !$var )
  4. if ($var)
  5. if ($var)
  6. if ( !$var )
  7. if ($var)
  8. if ( !$var )

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions