Paul et al, Here's the latest version of the script (the other one had some serious syntax errors :-)). I still get the following error when I run it and marc_word is not getting populated. Is the MARCaddword subroutine not working properly or am I confused about how to use it? 'sentence' is just the 'subfieldvalue' in marc_subfield_table, right? #!/usr/bin/perl -w use lib '/usr/local/koha/intranet/modules/'; use strict; use C4::Context; use C4::Biblio; my $dbh=C4::Context->dbh; #FIXME: for now tag 100 is hardcoded; eventually I plan #to derive a list of tags (and subfields?) from an outfile my $tag="100"; my $query="SELECT bibid,tag,tagorder,subfieldid,subfieldorder,subfieldvalue FROM marc_subfield_table WHERE tag=? LIMIT 0,20"; my $sth=$dbh->prepare($query); $sth->execute($tag); while (my $data=$sth->fetchrow_hashref()){ MARCaddword($dbh,$data->{'bibid'},$data->{'tag'},$data->{'subfieldid'},$data->{'subfieldorder'},$data->{'subfieldvalue'}); } $dbh->disconnect();