#!/usr/bin/perl use strict; use warnings; use CGI qw/:standard/; use OpenDict; my $root = $ENV{DOCUMENT_ROOT}; print header(-type=>'application/json'); my $xml = OpenDict->connect( db => "$root/xml.db"); my $sth = $xml->dbh->prepare("SELECT substr(normalized,1,1) AS letter, COUNT(*) from entry group by letter order by letter;"); $sth->execute(); my @results; my @row; while (@row = $sth->fetchrow_array) { push @results, $row[1]; } $xml->close; print "[",join(",",@results),"]";