#get data from DB my $sth = $dbh->prepare("SELECT * FROM publications") or error($cgi, "Error #1"); $sth->execute( ) or error($cgi, "Error #2: ". $dbh->errstr( )); #loop through data while (my $data = $sth->fetchrow_hashref) { #pull out only the first 15 words from the pubText field #this is where I need suggestions, the code below does not work while ($count < 15){ @copy = split " ", $data->{pubText}; $count ++ } #print resulting data print qq{