Looks like you're just lower casing your result set keys ... you should be able to simplify via DBI's FetchHashKeyName param. Added with a combination of selectall_arrayref. (code not tested):
!#/usr/bin/perl
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(-oldstyle_urls :standard);
use DBI;
use DBD::ODBC;
use JSON;
my $q = CGI->new;
my $search = $q->param('search') || "";
my $user = "user";
my $pwd = "pwd";
my $dbh =
DBI->connect("DBI:ODBC" ,$user ,$pass ,
{ PrintError => 0, FetchHashKeyName => 'NAME_lc' } ) or
die "Can not connect to ODBC database: $DBI::errstr\n" ;
my $sql =
qq{SELECT name,city,state from mytable where name like ? limit 5};
my $data =
$dbh->selectall_arrayref( $sql, { Slice => {} }, $search.'%' );
print $q->header(-type => "application/json", -charset => "utf-8");
print encode_json( $data )