Still not sure what you are doing here. But I tried to make some simplifications in the parsing part. I didn't really look in any detail at the DB part. I think you just need a HoA (Hash of Array). Each word would have a list of line numbers that it appeared on. A "unique" word would have just one line number in its array. Past that I'm not sure what this app is trying to do.
#!/usr/bin/perl use strict; use warnings; use DBI; my $searcher = "owner.manager, owner.owner, owner.manown"; my $dbh = DBI->connect('DBI:mysql:db;host=localhost', 'user', 'pass') or die "Database connection: $!"; open( FILE, '<', $ARGV[0] ) || die "unable to open $ARGV[0]!"; my $line_num =0; my %words = (); #hash of array, list of line numbers per #each word while ( my $line = <FILE> ) { $line_num++; foreach my $word (split (/\s+/, $line)) { $word =~ tr/^[a-zA-Z-]//; $word =~ s|(\'.*)\b||g; #maybe ?? not sure: what's->what? push (@{$words{$word}}, $line_num); } } # for every word, do a search... # a "unique word" would be one who's array of line numbers has # exactly 1 number # I don't think that is what you wanted? # I think what was meant is do one search per each word? foreach my $word (%words) { # @{words{$word}} is array of line numbers that word appeared # upon # line number appears twice if word appeared twice on that # line ... do something in DB with $word.... } # $uword { '$seen{ $word }[ 1 ]' } - should be the line(s) of test th +e search string came from #no, that would be @{words{$word}}

In reply to Re^3: error joining hashref of an arrayref by Marshall
in thread error joining hashref of an arrayref by ag4ve

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.