fadingjava has asked for the wisdom of the Perl Monks concerning the following question:
my $dbh = DBI->connect("dbi:mysql:concordance","sid" , $password); my @row = $dbh->selectcol_arrayref("select doc from doc"); @single_uniq = grep { ! $seen{$_} ++ } @single; my @row = $dbh->selectall_arrayref("select word,word_id from single_wo +rds"); my $row1 = $dbh->selectall_arrayref("select max(word_id) from single_w +ords"); $count = ($row1->[0][0]); $x = ($row1->[0][0]); $nfound = 0; single:for ($j=0;$j<=$#single_uniq;$j++){ $frequency = ($seen{$single_uniq[$j]}); word:for ($i= 0; $i<= $count ; $i++){ if ("$single_uniq[$j]" eq "$row[0][$i][0]"){ $found = 1; if ($found){ $dbh->do ("insert into single_frequency values('$row +[0][$i][0]',$frequency,'$row[0][$i][1]')"); } else { $nfound = ($nfound + 1); if ($nfound = 0){ $dbh->do ("insert into single_words values('','$single_un +iq[$j]',1)"); my $max1 = $dbh->selectall_arrayref("select max(word_id) f +rom single_words"); $dbh->do ("insert into single_frequency values('$single_un +iq[$j]',$frequency,'$max1->[0][0]')"); $x = ($x + 1); } } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: need help in searching arrayrefs
by halley (Prior) on Feb 12, 2004 at 15:38 UTC | |
|
Re: need help in searching arrayrefs
by cchampion (Curate) on Feb 13, 2004 at 01:48 UTC | |
|
Re: need help in searching arrayrefs
by ChrisR (Hermit) on Feb 12, 2004 at 15:07 UTC | |
by fadingjava (Acolyte) on Feb 12, 2004 at 15:23 UTC |