get '/' => sub { # Create customers list my $db = connect_db(); my $sth=$db->prepare("SELECT shortcut,nameheb FROM cust"); $sth->execute() or die "$DBI::errstr"; # Create customer HASH my %cust_name; my @cust_code; while(my ($shortcut,$name) = $sth->fetchrow_array()) { $cust_name{$shortcut}="$name"; } $sth->finish(); template 'index', { hash => \%cust_name }; };