sub { my $sth; my $cat_db = $DB->table('Category'); $cat_db->select_options ("ORDER BY RAND()", "LIMIT $_[0]"); my $sth = $cat_db->select ( { FatherID => 4}, ['Full_Name','Name'] ); my @output; while (my $cat = $sth->fetchrow_hashref) { if (length $cat->{Name} > 23) { $cat->{Name} = substr($cat->{Name}, 0, 23) . '..'; } $cat->{URL} = "$CFG->{build_root_url}/" . $cat_db->as_url($cat->{Full_Name}) . "/"; push @output, $cat; } return {catrand => \@output}; }