in reply to Re^2: error joining hashref of an arrayref
in thread error joining hashref of an arrayref
#!/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}}
|
|---|