my ($major,$minor) = get_my_sql_version(); my $statement; if ($major < 5) { $statement = 'show variables'; } elsif ("$major.$minor" eq "5.0") { $statement = 'show global variables'; } elsif ("$major.$minor" gt "5.0") { $statement = 'Select * from information_schema.global_variables order by 1'; }; $dbh->execute($statement); ...