Currently my code take long amount of time to run.
Sample Output:# We'll pass it as ref to SCALAR and receive it in a ref to ARRAY use constant ARTICLES => 100; use constant ENTRIES => 2000; #Articles foreach $article ( 1 .. ARTICLES ) { foreach $feature ( 1 .. 10 ) { $A->{$article}{$feature} = int rand(100); } } #Entries foreach $entry ( 1 .. ENTRIES ) { foreach $feature ( 1 .. 10 ) { $E->{$entry}{$feature} = int rand(100); } } $| += 1; foreach my $article ( 1 .. ARTICLES ) { foreach $entry ( 1 .. ENTRIES ) { # print "." if $entry % 1000 == 0; my $count; foreach $feature ( 1 .. 10 ) { if ( $E->{$entry}{$feature} eq $A->{$article}{$feature}){ $count += 1; } } if ( $count >= 3 ) { #Found match push @{ $X->{$article} }, $entry; } } } foreach my $article ( sort { $a <=> $b } keys %{$X} ) { print "$article:"; foreach my $entry ( @{ $X->{$article} } ) { print "\t$entry"; } print "\n"; }
1: 1120 7: 1563 12: 341 24: 4 25: 1977 28: 455 30: 143 36: 618 43: 802 44: 107 48: 263 50: 1824 53: 1734 60: 1778 64: 350 448 71: 1673 72: 691 75: 780 76: 265 1669 80: 1260 85: 1429 1966 98: 758 99: 60Any better and faster method would be useful. Currently it works fine, but for 10000 articles and 200,000 entries, this takes a lot of time.
In reply to Articles matching entries by artist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |